aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorTedd Hansen2008-01-12 09:44:01 +0000
committerTedd Hansen2008-01-12 09:44:01 +0000
commit011abad0537d4e77860765b691622c0e03a98e2e (patch)
tree27449e2d8281649cb60c557c46c19727ebd00ba5 /OpenSim
parentChanged URL in example to avoid RIAA issues. (diff)
downloadopensim-SC-011abad0537d4e77860765b691622c0e03a98e2e.zip
opensim-SC-011abad0537d4e77860765b691622c0e03a98e2e.tar.gz
opensim-SC-011abad0537d4e77860765b691622c0e03a98e2e.tar.bz2
opensim-SC-011abad0537d4e77860765b691622c0e03a98e2e.tar.xz
ScriptServer protocol now correctly casts datatypes -- ready for implementing
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/TRPC_Remote.cs38
1 files changed, 33 insertions, 5 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/TRPC_Remote.cs b/OpenSim/Region/ScriptEngine/Common/TRPC_Remote.cs
index 8296bea..b6c2e93 100644
--- a/OpenSim/Region/ScriptEngine/Common/TRPC_Remote.cs
+++ b/OpenSim/Region/ScriptEngine/Common/TRPC_Remote.cs
@@ -13,6 +13,17 @@ namespace OpenSim.Region.ScriptEngine.Common
13 13
14 public delegate void ReceiveCommandDelegate(int ID, string Command, params object[] p); 14 public delegate void ReceiveCommandDelegate(int ID, string Command, params object[] p);
15 public event ReceiveCommandDelegate ReceiveCommand; 15 public event ReceiveCommandDelegate ReceiveCommand;
16 System.Collections.Generic.Dictionary<string, Type> TypeDictionary = new Dictionary<string, Type>();
17 Type[] Types =
18 {
19 typeof(System.String),
20 typeof(System.Int16),
21 typeof(System.Int32),
22 typeof(System.Int64),
23 typeof(System.Double),
24 typeof(System.Decimal),
25 typeof(System.Array)
26 };
16 27
17 // TODO: Maybe we should move queue into TCPSocket so we won't have to keep one queue instance per connection 28 // TODO: Maybe we should move queue into TCPSocket so we won't have to keep one queue instance per connection
18 private System.Collections.Generic.Dictionary<int, InQueueStruct> InQueue = new Dictionary<int, InQueueStruct>(); 29 private System.Collections.Generic.Dictionary<int, InQueueStruct> InQueue = new Dictionary<int, InQueueStruct>();
@@ -30,6 +41,12 @@ namespace OpenSim.Region.ScriptEngine.Common
30 TCPS.ClientConnected += new TCPCommon.ClientConnectedDelegate(TCPS_ClientConnected); 41 TCPS.ClientConnected += new TCPCommon.ClientConnectedDelegate(TCPS_ClientConnected);
31 TCPS.DataReceived += new TCPCommon.DataReceivedDelegate(TCPS_DataReceived); 42 TCPS.DataReceived += new TCPCommon.DataReceivedDelegate(TCPS_DataReceived);
32 //TCPS.StartListen(); 43 //TCPS.StartListen();
44
45 // Make a lookup dictionary for types
46 foreach (Type t in Types)
47 {
48 TypeDictionary.Add(t.ToString(), t);
49 }
33 } 50 }
34 51
35 void TCPS_ClientConnected(int ID, System.Net.EndPoint Remote) 52 void TCPS_ClientConnected(int ID, System.Net.EndPoint Remote)
@@ -109,15 +126,18 @@ namespace OpenSim.Region.ScriptEngine.Common
109 { 126 {
110 string cmd = parts[0]; 127 string cmd = parts[0];
111 int paramCount = parts.Length - 1; 128 int paramCount = parts.Length - 1;
112 string[] param = null; 129 object[] param = null;
113 130
114 if (paramCount > 0) 131 if (paramCount > 0)
115 { 132 {
116 // Process all parameters (decoding them from URL encoding) 133 // Process all parameters (decoding them from URL encoding)
117 param = new string[paramCount]; 134 param = new object[paramCount];
118 for (int i = 1; i < parts.Length; i++) 135 for (int i = 1; i < parts.Length; i++)
119 { 136 {
120 param[i - 1] = System.Web.HttpUtility.UrlDecode(parts[i]); 137 string[] spl;
138 spl = System.Web.HttpUtility.UrlDecode(parts[i]).Split('|');
139 string t = spl[0];
140 param[i - 1] = Convert.ChangeType(spl[1], TypeLookup(t));
121 } 141 }
122 } 142 }
123 143
@@ -126,6 +146,14 @@ namespace OpenSim.Region.ScriptEngine.Common
126 } 146 }
127 } 147 }
128 148
149 private Type TypeLookup(string t)
150 {
151 Type ret = TypeDictionary[t];
152 if (ret != null)
153 return ret;
154 return typeof(object);
155 }
156
129 public void SendCommand(int ID, string Command, params object[] p) 157 public void SendCommand(int ID, string Command, params object[] p)
130 { 158 {
131 // Call PacketFactory to have it create a packet for us 159 // Call PacketFactory to have it create a packet for us
@@ -134,7 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Common
134 string tmpStr = Command; 162 string tmpStr = Command;
135 for (int i = 0; i < p.Length; i++) 163 for (int i = 0; i < p.Length; i++)
136 { 164 {
137 tmpStr += "," + System.Web.HttpUtility.UrlEncode(p[i].ToString()); // .Replace(",", "%44") 165 tmpStr += "," + p[i].GetType().ToString() + "|" + System.Web.HttpUtility.UrlEncode(p[i].ToString()); // .Replace(",", "%44")
138 } 166 }
139 tmpStr += "\n"; 167 tmpStr += "\n";
140 byte[] byteData = Encoding.ASCII.GetBytes(tmpStr); 168 byte[] byteData = Encoding.ASCII.GetBytes(tmpStr);