aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common
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/Common
parentScriptServer communication protocol (v1), primitive RPC-like TCP client/server (diff)
downloadopensim-SC-e7dbaad04f1599965cf8ad709828a17fbd6f8a3a.zip
opensim-SC-e7dbaad04f1599965cf8ad709828a17fbd6f8a3a.tar.gz
opensim-SC-e7dbaad04f1599965cf8ad709828a17fbd6f8a3a.tar.bz2
opensim-SC-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/Common')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/TRPC/TCPClient.cs26
1 files changed, 21 insertions, 5 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