aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorTedd Hansen2008-01-12 01:14:31 +0000
committerTedd Hansen2008-01-12 01:14:31 +0000
commite7dbaad04f1599965cf8ad709828a17fbd6f8a3a (patch)
tree7187520c6a30055bc005d11d2b1666e311735504 /OpenSim/Region/ScriptEngine
parentScriptServer communication protocol (v1), primitive RPC-like TCP client/server (diff)
downloadopensim-SC_OLD-e7dbaad04f1599965cf8ad709828a17fbd6f8a3a.zip
opensim-SC_OLD-e7dbaad04f1599965cf8ad709828a17fbd6f8a3a.tar.gz
opensim-SC_OLD-e7dbaad04f1599965cf8ad709828a17fbd6f8a3a.tar.bz2
opensim-SC_OLD-e7dbaad04f1599965cf8ad709828a17fbd6f8a3a.tar.xz
New ScriptServer protocol successfully implemented.
Still needs hooking up for all commands in both ends, separation of local and remote LSL-commands, etc.
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/TRPC/TCPClient.cs26
-rw-r--r--OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs36
2 files changed, 52 insertions, 10 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/TRPC/TCPClient.cs b/OpenSim/Region/ScriptEngine/Common/TRPC/TCPClient.cs
index 3230614..e0a46c5 100644
--- a/OpenSim/Region/ScriptEngine/Common/TRPC/TCPClient.cs
+++ b/OpenSim/Region/ScriptEngine/Common/TRPC/TCPClient.cs
@@ -7,7 +7,7 @@ using System.Text;
7 7
8namespace OpenSim.Region.ScriptEngine.Common.TRPC 8namespace OpenSim.Region.ScriptEngine.Common.TRPC
9{ 9{
10 public class TCPClient: TCPCommon.ClientInterface 10 public class TCPClient : TCPCommon.ClientInterface
11 { 11 {
12 12
13 public TCPClient() 13 public TCPClient()
@@ -31,11 +31,19 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
31 { 31 {
32 Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 32 Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
33 IPEndPoint ipe = new IPEndPoint(IPAddress.Parse(RemoteHost), RemotePort); 33 IPEndPoint ipe = new IPEndPoint(IPAddress.Parse(RemoteHost), RemotePort);
34 newsock.BeginConnect(ipe, new AsyncCallback(asyncConnected), newsock); 34 //newsock.BeginConnect(ipe, new AsyncCallback(asyncConnected), newsock);
35 35 newsock.Connect(ipe);
36 36 }
37 public int ConnectAndReturnID(string RemoteHost, int RemotePort)
38 {
39 Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
40 IPEndPoint ipe = new IPEndPoint(IPAddress.Parse(RemoteHost), RemotePort);
41 //newsock.BeginConnect(ipe, new AsyncCallback(asyncConnected), newsock);
42 newsock.Connect(ipe);
43 return ProcessConnection(newsock);
37 } 44 }
38 45
46
39 public void Disconnect(int ID) 47 public void Disconnect(int ID)
40 { 48 {
41 Clients[ID].Disconnect(); 49 Clients[ID].Disconnect();
@@ -44,9 +52,15 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
44 void asyncConnected(IAsyncResult iar) 52 void asyncConnected(IAsyncResult iar)
45 { 53 {
46 Socket client = (Socket)iar.AsyncState; 54 Socket client = (Socket)iar.AsyncState;
55 client.EndConnect(iar);
56 ProcessConnection(client);
57 }
58
59 private int ProcessConnection(Socket client)
60 {
47 try 61 try
48 { 62 {
49 client.EndConnect(iar); 63
50 64
51 65
52 int id = ClientCount++; 66 int id = ClientCount++;
@@ -69,12 +83,14 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
69 if (ClientConnected != null) 83 if (ClientConnected != null)
70 ClientConnected(id, client.RemoteEndPoint); 84 ClientConnected(id, client.RemoteEndPoint);
71 85
86 return id;
72 } 87 }
73 catch (SocketException sex) 88 catch (SocketException sex)
74 { 89 {
75 if (ConnectError != null) 90 if (ConnectError != null)
76 ConnectError(sex.Message); 91 ConnectError(sex.Message);
77 } 92 }
93 return -1;
78 } 94 }
79 95
80 96
diff --git a/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs b/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs
index 1b37378..39f2695 100644
--- a/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs
@@ -30,6 +30,7 @@ using System;
30using libsecondlife; 30using libsecondlife;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.ScriptEngine.Common; 32using OpenSim.Region.ScriptEngine.Common;
33using OpenSim.Region.ScriptEngine.Common.TRPC;
33 34
34namespace OpenSim.Region.ScriptEngine.RemoteServer 35namespace OpenSim.Region.ScriptEngine.RemoteServer
35{ 36{
@@ -41,14 +42,23 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
41 { 42 {
42 43
43 System.Collections.Generic.Dictionary<uint, ScriptServerInterfaces.ServerRemotingObject> remoteScript = new System.Collections.Generic.Dictionary<uint, ScriptServerInterfaces.ServerRemotingObject>(); 44 System.Collections.Generic.Dictionary<uint, ScriptServerInterfaces.ServerRemotingObject> remoteScript = new System.Collections.Generic.Dictionary<uint, ScriptServerInterfaces.ServerRemotingObject>();
45 TCPClient m_TCPClient;
46 TRPC_Remote RPC;
47 int myScriptServerID;
44 48
49 string remoteHost = "127.0.0.1";
50 int remotePort = 8010;
45 51
46 private ScriptEngine myScriptEngine; 52 private ScriptEngine myScriptEngine;
47 public EventManager(ScriptEngine _ScriptEngine) 53 public EventManager(ScriptEngine _ScriptEngine)
48 { 54 {
49 myScriptEngine = _ScriptEngine; 55 myScriptEngine = _ScriptEngine;
50 56
51 57 m_TCPClient = new TCPClient();
58 RPC = new TRPC_Remote(m_TCPClient);
59 RPC.ReceiveCommand += new TRPC_Remote.ReceiveCommandDelegate(RPC_ReceiveCommand);
60 myScriptServerID = m_TCPClient.ConnectAndReturnID(remoteHost, remotePort);
61
52 myScriptEngine.Log.Verbose("RemoteEngine", "Hooking up to server events"); 62 myScriptEngine.Log.Verbose("RemoteEngine", "Hooking up to server events");
53 //myScriptEngine.World.EventManager.OnObjectGrab += touch_start; 63 //myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
54 myScriptEngine.World.EventManager.OnRezScript += OnRezScript; 64 myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
@@ -57,16 +67,32 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
57 67
58 } 68 }
59 69
70 void RPC_ReceiveCommand(int ID, string Command, params object[] p)
71 {
72 myScriptEngine.Log.Notice("REMOTESERVER", "Received command: '" + Command + "'");
73 if (p != null)
74 {
75 for (int i = 0; i < p.Length; i++)
76 {
77 myScriptEngine.Log.Notice("REMOTESERVER", "Param " + i + ": " + p[i].ToString());
78 }
79 }
80
81 }
82
60 83
61 public void OnRezScript(uint localID, LLUUID itemID, string script) 84 public void OnRezScript(uint localID, LLUUID itemID, string script)
62 { 85 {
63 // WE ARE CREATING A NEW SCRIPT ... CREATE SCRIPT, GET A REMOTEID THAT WE MAP FROM LOCALID 86 // WE ARE CREATING A NEW SCRIPT ... CREATE SCRIPT, GET A REMOTEID THAT WE MAP FROM LOCALID
64 myScriptEngine.Log.Verbose("RemoteEngine", "Creating new script (with connection)"); 87 myScriptEngine.Log.Verbose("RemoteEngine", "Creating new script (with connection)");
65 88
89 // Temp for now: We have one connection only - this is hardcoded in myScriptServerID
90 RPC.SendCommand(myScriptServerID, "OnRezScript", script);
66 91
67 ScriptServerInterfaces.ServerRemotingObject obj = myScriptEngine.m_RemoteServer.Connect("localhost", 1234); 92 //ScriptServerInterfaces.ServerRemotingObject obj = myScriptEngine.m_RemoteServer.Connect("localhost", 1234);
68 remoteScript.Add(localID, obj); 93 //remoteScript.Add(localID, obj);
69 remoteScript[localID].Events().OnRezScript(localID, itemID, script); 94 //remoteScript[localID].Events().OnRezScript(localID, itemID, script);
95
70 96
71 } 97 }
72 98