aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/ScriptServer/ScriptServerMain.cs29
-rw-r--r--OpenSim/Region/ScriptEngine/Common/TRPC/TCPClient.cs26
-rw-r--r--OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs36
3 files changed, 77 insertions, 14 deletions
diff --git a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs
index bdd6f18..f86aaba 100644
--- a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs
+++ b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs
@@ -31,6 +31,7 @@ using OpenSim.Framework;
31using OpenSim.Framework.Console; 31using OpenSim.Framework.Console;
32using OpenSim.Grid.ScriptServer.ScriptServer; 32using OpenSim.Grid.ScriptServer.ScriptServer;
33using OpenSim.Region.ScriptEngine.Common; 33using OpenSim.Region.ScriptEngine.Common;
34using OpenSim.Region.ScriptEngine.Common.TRPC;
34 35
35namespace OpenSim.Grid.ScriptServer 36namespace OpenSim.Grid.ScriptServer
36{ 37{
@@ -39,7 +40,7 @@ namespace OpenSim.Grid.ScriptServer
39 // 40 //
40 // Root object. Creates objects used. 41 // Root object. Creates objects used.
41 // 42 //
42 private int listenPort = 1234; 43 private int listenPort = 8010;
43 private readonly string m_logFilename = ("scriptserver.log"); 44 private readonly string m_logFilename = ("scriptserver.log");
44 private LogBase m_log; 45 private LogBase m_log;
45 46
@@ -49,12 +50,15 @@ namespace OpenSim.Grid.ScriptServer
49 // Objects we use 50 // Objects we use
50 internal RegionCommManager RegionScriptDaemon; // Listen for incoming from region 51 internal RegionCommManager RegionScriptDaemon; // Listen for incoming from region
51 internal ScriptEngineManager ScriptEngines; // Loads scriptengines 52 internal ScriptEngineManager ScriptEngines; // Loads scriptengines
52 internal RemotingServer m_RemotingServer; 53 //internal RemotingServer m_RemotingServer;
54 internal TCPServer m_TCPServer;
55 internal TRPC_Remote RPC;
53 56
54 public ScriptServerMain() 57 public ScriptServerMain()
55 { 58 {
56 m_log = CreateLog(); 59 m_log = CreateLog();
57 60
61
58 // Set up script engine mananger 62 // Set up script engine mananger
59 ScriptEngines = new ScriptEngineManager(this, m_log); 63 ScriptEngines = new ScriptEngineManager(this, m_log);
60 64
@@ -62,10 +66,27 @@ namespace OpenSim.Grid.ScriptServer
62 Engine = ScriptEngines.LoadEngine("DotNetEngine"); 66 Engine = ScriptEngines.LoadEngine("DotNetEngine");
63 67
64 // Set up server 68 // Set up server
65 m_RemotingServer = new RemotingServer(listenPort, "DotNetEngine"); 69 //m_RemotingServer = new RemotingServer(listenPort, "DotNetEngine");
70 m_TCPServer = new TCPServer(listenPort);
71 RPC = new TRPC_Remote(m_TCPServer);
72 RPC.ReceiveCommand += new TRPC_Remote.ReceiveCommandDelegate(RPC_ReceiveCommand);
73 m_TCPServer.StartListen();
74
66 System.Console.ReadLine(); 75 System.Console.ReadLine();
67 } 76 }
68 77
78 private void RPC_ReceiveCommand(int ID, string Command, object[] p)
79 {
80 m_log.Notice("SERVER", "Received command: '" + Command + "'");
81 if (p != null)
82 {
83 for (int i = 0; i < p.Length; i++)
84 {
85 m_log.Notice("SERVER", "Param " + i + ": " + p[i].ToString());
86 }
87 }
88 }
89
69 ~ScriptServerMain() 90 ~ScriptServerMain()
70 { 91 {
71 } 92 }
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