New ScriptServer protocol successfully implemented.
Still needs hooking up for all commands in both ends, separation of local and remote LSL-commands, etc.ThreadPoolClientBranch
parent
1e9a66cbaa
commit
e7dbaad04f
|
@ -31,6 +31,7 @@ using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Grid.ScriptServer.ScriptServer;
|
using OpenSim.Grid.ScriptServer.ScriptServer;
|
||||||
using OpenSim.Region.ScriptEngine.Common;
|
using OpenSim.Region.ScriptEngine.Common;
|
||||||
|
using OpenSim.Region.ScriptEngine.Common.TRPC;
|
||||||
|
|
||||||
namespace OpenSim.Grid.ScriptServer
|
namespace OpenSim.Grid.ScriptServer
|
||||||
{
|
{
|
||||||
|
@ -39,7 +40,7 @@ namespace OpenSim.Grid.ScriptServer
|
||||||
//
|
//
|
||||||
// Root object. Creates objects used.
|
// Root object. Creates objects used.
|
||||||
//
|
//
|
||||||
private int listenPort = 1234;
|
private int listenPort = 8010;
|
||||||
private readonly string m_logFilename = ("scriptserver.log");
|
private readonly string m_logFilename = ("scriptserver.log");
|
||||||
private LogBase m_log;
|
private LogBase m_log;
|
||||||
|
|
||||||
|
@ -49,12 +50,15 @@ namespace OpenSim.Grid.ScriptServer
|
||||||
// Objects we use
|
// Objects we use
|
||||||
internal RegionCommManager RegionScriptDaemon; // Listen for incoming from region
|
internal RegionCommManager RegionScriptDaemon; // Listen for incoming from region
|
||||||
internal ScriptEngineManager ScriptEngines; // Loads scriptengines
|
internal ScriptEngineManager ScriptEngines; // Loads scriptengines
|
||||||
internal RemotingServer m_RemotingServer;
|
//internal RemotingServer m_RemotingServer;
|
||||||
|
internal TCPServer m_TCPServer;
|
||||||
|
internal TRPC_Remote RPC;
|
||||||
|
|
||||||
public ScriptServerMain()
|
public ScriptServerMain()
|
||||||
{
|
{
|
||||||
m_log = CreateLog();
|
m_log = CreateLog();
|
||||||
|
|
||||||
|
|
||||||
// Set up script engine mananger
|
// Set up script engine mananger
|
||||||
ScriptEngines = new ScriptEngineManager(this, m_log);
|
ScriptEngines = new ScriptEngineManager(this, m_log);
|
||||||
|
|
||||||
|
@ -62,10 +66,27 @@ namespace OpenSim.Grid.ScriptServer
|
||||||
Engine = ScriptEngines.LoadEngine("DotNetEngine");
|
Engine = ScriptEngines.LoadEngine("DotNetEngine");
|
||||||
|
|
||||||
// Set up server
|
// Set up server
|
||||||
m_RemotingServer = new RemotingServer(listenPort, "DotNetEngine");
|
//m_RemotingServer = new RemotingServer(listenPort, "DotNetEngine");
|
||||||
|
m_TCPServer = new TCPServer(listenPort);
|
||||||
|
RPC = new TRPC_Remote(m_TCPServer);
|
||||||
|
RPC.ReceiveCommand += new TRPC_Remote.ReceiveCommandDelegate(RPC_ReceiveCommand);
|
||||||
|
m_TCPServer.StartListen();
|
||||||
|
|
||||||
System.Console.ReadLine();
|
System.Console.ReadLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RPC_ReceiveCommand(int ID, string Command, object[] p)
|
||||||
|
{
|
||||||
|
m_log.Notice("SERVER", "Received command: '" + Command + "'");
|
||||||
|
if (p != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < p.Length; i++)
|
||||||
|
{
|
||||||
|
m_log.Notice("SERVER", "Param " + i + ": " + p[i].ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
~ScriptServerMain()
|
~ScriptServerMain()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ using System.Text;
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.Common.TRPC
|
namespace OpenSim.Region.ScriptEngine.Common.TRPC
|
||||||
{
|
{
|
||||||
public class TCPClient: TCPCommon.ClientInterface
|
public class TCPClient : TCPCommon.ClientInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public TCPClient()
|
public TCPClient()
|
||||||
|
@ -31,10 +31,18 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
|
||||||
{
|
{
|
||||||
Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
IPEndPoint ipe = new IPEndPoint(IPAddress.Parse(RemoteHost), RemotePort);
|
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)
|
public void Disconnect(int ID)
|
||||||
{
|
{
|
||||||
|
@ -44,9 +52,15 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
|
||||||
void asyncConnected(IAsyncResult iar)
|
void asyncConnected(IAsyncResult iar)
|
||||||
{
|
{
|
||||||
Socket client = (Socket)iar.AsyncState;
|
Socket client = (Socket)iar.AsyncState;
|
||||||
|
client.EndConnect(iar);
|
||||||
|
ProcessConnection(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int ProcessConnection(Socket client)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
client.EndConnect(iar);
|
|
||||||
|
|
||||||
|
|
||||||
int id = ClientCount++;
|
int id = ClientCount++;
|
||||||
|
@ -69,12 +83,14 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
|
||||||
if (ClientConnected != null)
|
if (ClientConnected != null)
|
||||||
ClientConnected(id, client.RemoteEndPoint);
|
ClientConnected(id, client.RemoteEndPoint);
|
||||||
|
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
catch (SocketException sex)
|
catch (SocketException sex)
|
||||||
{
|
{
|
||||||
if (ConnectError != null)
|
if (ConnectError != null)
|
||||||
ConnectError(sex.Message);
|
ConnectError(sex.Message);
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ using System;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.ScriptEngine.Common;
|
using OpenSim.Region.ScriptEngine.Common;
|
||||||
|
using OpenSim.Region.ScriptEngine.Common.TRPC;
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.RemoteServer
|
namespace OpenSim.Region.ScriptEngine.RemoteServer
|
||||||
{
|
{
|
||||||
|
@ -41,14 +42,23 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
|
||||||
{
|
{
|
||||||
|
|
||||||
System.Collections.Generic.Dictionary<uint, ScriptServerInterfaces.ServerRemotingObject> remoteScript = new System.Collections.Generic.Dictionary<uint, ScriptServerInterfaces.ServerRemotingObject>();
|
System.Collections.Generic.Dictionary<uint, ScriptServerInterfaces.ServerRemotingObject> remoteScript = new System.Collections.Generic.Dictionary<uint, ScriptServerInterfaces.ServerRemotingObject>();
|
||||||
|
TCPClient m_TCPClient;
|
||||||
|
TRPC_Remote RPC;
|
||||||
|
int myScriptServerID;
|
||||||
|
|
||||||
|
string remoteHost = "127.0.0.1";
|
||||||
|
int remotePort = 8010;
|
||||||
|
|
||||||
private ScriptEngine myScriptEngine;
|
private ScriptEngine myScriptEngine;
|
||||||
public EventManager(ScriptEngine _ScriptEngine)
|
public EventManager(ScriptEngine _ScriptEngine)
|
||||||
{
|
{
|
||||||
myScriptEngine = _ScriptEngine;
|
myScriptEngine = _ScriptEngine;
|
||||||
|
|
||||||
|
m_TCPClient = new TCPClient();
|
||||||
|
RPC = new TRPC_Remote(m_TCPClient);
|
||||||
|
RPC.ReceiveCommand += new TRPC_Remote.ReceiveCommandDelegate(RPC_ReceiveCommand);
|
||||||
|
myScriptServerID = m_TCPClient.ConnectAndReturnID(remoteHost, remotePort);
|
||||||
|
|
||||||
myScriptEngine.Log.Verbose("RemoteEngine", "Hooking up to server events");
|
myScriptEngine.Log.Verbose("RemoteEngine", "Hooking up to server events");
|
||||||
//myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
|
//myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
|
||||||
myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
|
myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
|
||||||
|
@ -57,16 +67,32 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RPC_ReceiveCommand(int ID, string Command, params object[] p)
|
||||||
|
{
|
||||||
|
myScriptEngine.Log.Notice("REMOTESERVER", "Received command: '" + Command + "'");
|
||||||
|
if (p != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < p.Length; i++)
|
||||||
|
{
|
||||||
|
myScriptEngine.Log.Notice("REMOTESERVER", "Param " + i + ": " + p[i].ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void OnRezScript(uint localID, LLUUID itemID, string script)
|
public void OnRezScript(uint localID, LLUUID itemID, string script)
|
||||||
{
|
{
|
||||||
// WE ARE CREATING A NEW SCRIPT ... CREATE SCRIPT, GET A REMOTEID THAT WE MAP FROM LOCALID
|
// WE ARE CREATING A NEW SCRIPT ... CREATE SCRIPT, GET A REMOTEID THAT WE MAP FROM LOCALID
|
||||||
myScriptEngine.Log.Verbose("RemoteEngine", "Creating new script (with connection)");
|
myScriptEngine.Log.Verbose("RemoteEngine", "Creating new script (with connection)");
|
||||||
|
|
||||||
|
// Temp for now: We have one connection only - this is hardcoded in myScriptServerID
|
||||||
|
RPC.SendCommand(myScriptServerID, "OnRezScript", script);
|
||||||
|
|
||||||
ScriptServerInterfaces.ServerRemotingObject obj = myScriptEngine.m_RemoteServer.Connect("localhost", 1234);
|
//ScriptServerInterfaces.ServerRemotingObject obj = myScriptEngine.m_RemoteServer.Connect("localhost", 1234);
|
||||||
remoteScript.Add(localID, obj);
|
//remoteScript.Add(localID, obj);
|
||||||
remoteScript[localID].Events().OnRezScript(localID, itemID, script);
|
//remoteScript[localID].Events().OnRezScript(localID, itemID, script);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue