From e7dbaad04f1599965cf8ad709828a17fbd6f8a3a Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Sat, 12 Jan 2008 01:14:31 +0000 Subject: New ScriptServer protocol successfully implemented. Still needs hooking up for all commands in both ends, separation of local and remote LSL-commands, etc. --- .../Region/ScriptEngine/Common/TRPC/TCPClient.cs | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Common') 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; namespace OpenSim.Region.ScriptEngine.Common.TRPC { - public class TCPClient: TCPCommon.ClientInterface + public class TCPClient : TCPCommon.ClientInterface { public TCPClient() @@ -31,11 +31,19 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC { Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPEndPoint ipe = new IPEndPoint(IPAddress.Parse(RemoteHost), RemotePort); - newsock.BeginConnect(ipe, new AsyncCallback(asyncConnected), newsock); - - + //newsock.BeginConnect(ipe, new AsyncCallback(asyncConnected), newsock); + newsock.Connect(ipe); + } + public int ConnectAndReturnID(string RemoteHost, int RemotePort) + { + Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + IPEndPoint ipe = new IPEndPoint(IPAddress.Parse(RemoteHost), RemotePort); + //newsock.BeginConnect(ipe, new AsyncCallback(asyncConnected), newsock); + newsock.Connect(ipe); + return ProcessConnection(newsock); } + public void Disconnect(int ID) { Clients[ID].Disconnect(); @@ -44,9 +52,15 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC void asyncConnected(IAsyncResult iar) { Socket client = (Socket)iar.AsyncState; + client.EndConnect(iar); + ProcessConnection(client); + } + + private int ProcessConnection(Socket client) + { try { - client.EndConnect(iar); + int id = ClientCount++; @@ -69,12 +83,14 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC if (ClientConnected != null) ClientConnected(id, client.RemoteEndPoint); + return id; } catch (SocketException sex) { if (ConnectError != null) ConnectError(sex.Message); } + return -1; } -- cgit v1.1