diff options
author | teravus | 2013-10-04 20:53:01 -0500 |
---|---|---|
committer | teravus | 2013-10-04 20:53:01 -0500 |
commit | 31246ecd04c0f57631587e25ae0245d086098ddc (patch) | |
tree | b54e399e84366a75849dc406c1ec8c1fb5ef0fd9 /OpenSim/Server/Handlers | |
parent | * Add an initial complete frame timeout to the WebSocket processor to make it... (diff) | |
download | opensim-SC_OLD-31246ecd04c0f57631587e25ae0245d086098ddc.zip opensim-SC_OLD-31246ecd04c0f57631587e25ae0245d086098ddc.tar.gz opensim-SC_OLD-31246ecd04c0f57631587e25ae0245d086098ddc.tar.bz2 opensim-SC_OLD-31246ecd04c0f57631587e25ae0245d086098ddc.tar.xz |
* Added a unique and interesting WebSocket grid login processor by hijacking the LLSD login code. This sends the data through the normal login channels and spits out a JSON object back that mimics the login response. Feel free to comment on the best way to set this up as a config option.
Diffstat (limited to 'OpenSim/Server/Handlers')
-rw-r--r-- | OpenSim/Server/Handlers/Login/LLLoginHandlers.cs | 56 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs | 1 |
2 files changed, 57 insertions, 0 deletions
diff --git a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs index f83a239..e4a0ffa 100644 --- a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs +++ b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs | |||
@@ -53,6 +53,7 @@ namespace OpenSim.Server.Handlers.Login | |||
53 | 53 | ||
54 | private ILoginService m_LocalService; | 54 | private ILoginService m_LocalService; |
55 | private bool m_Proxy; | 55 | private bool m_Proxy; |
56 | |||
56 | 57 | ||
57 | public LLLoginHandlers(ILoginService service, bool hasProxy) | 58 | public LLLoginHandlers(ILoginService service, bool hasProxy) |
58 | { | 59 | { |
@@ -213,6 +214,61 @@ namespace OpenSim.Server.Handlers.Login | |||
213 | return FailedOSDResponse(); | 214 | return FailedOSDResponse(); |
214 | } | 215 | } |
215 | 216 | ||
217 | public void HandleWebSocketLoginEvents(string path, WebSocketHttpServerHandler sock) | ||
218 | { | ||
219 | sock.MaxPayloadSize = 16384; //16 kb payload | ||
220 | sock.InitialMsgTimeout = 5000; //5 second first message to trigger at least one of these events | ||
221 | sock.NoDelay_TCP_Nagle = true; | ||
222 | sock.OnData += delegate(object sender, WebsocketDataEventArgs data) { sock.Close("fail"); }; | ||
223 | sock.OnPing += delegate(object sender, PingEventArgs pingdata) { sock.Close("fail"); }; | ||
224 | sock.OnPong += delegate(object sender, PongEventArgs pongdata) { sock.Close("fail"); }; | ||
225 | sock.OnText += delegate(object sender, WebsocketTextEventArgs text) | ||
226 | { | ||
227 | OSD request = null; | ||
228 | try | ||
229 | { | ||
230 | request = OSDParser.DeserializeJson(text.Data); | ||
231 | if (!(request is OSDMap)) | ||
232 | { | ||
233 | sock.SendMessage(OSDParser.SerializeJsonString(FailedOSDResponse())); | ||
234 | } | ||
235 | else | ||
236 | { | ||
237 | OSDMap req = request as OSDMap; | ||
238 | string first = req["firstname"].AsString(); | ||
239 | string last = req["lastname"].AsString(); | ||
240 | string passwd = req["passwd"].AsString(); | ||
241 | string start = req["startlocation"].AsString(); | ||
242 | string version = req["version"].AsString(); | ||
243 | string channel = req["channel"].AsString(); | ||
244 | string mac = req["mac"].AsString(); | ||
245 | string id0 = req["id0"].AsString(); | ||
246 | UUID scope = UUID.Zero; | ||
247 | IPEndPoint endPoint = | ||
248 | (sender as WebSocketHttpServerHandler).GetRemoteIPEndpoint(); | ||
249 | LoginResponse reply = null; | ||
250 | reply = m_LocalService.Login(first, last, passwd, start, scope, version, | ||
251 | channel, mac, id0, endPoint); | ||
252 | sock.SendMessage(OSDParser.SerializeJsonString(reply.ToOSDMap())); | ||
253 | |||
254 | } | ||
255 | |||
256 | } | ||
257 | catch (Exception) | ||
258 | { | ||
259 | sock.SendMessage(OSDParser.SerializeJsonString(FailedOSDResponse())); | ||
260 | } | ||
261 | finally | ||
262 | { | ||
263 | sock.Close("success"); | ||
264 | } | ||
265 | }; | ||
266 | |||
267 | sock.HandshakeAndUpgrade(); | ||
268 | |||
269 | } | ||
270 | |||
271 | |||
216 | private XmlRpcResponse FailedXMLRPCResponse() | 272 | private XmlRpcResponse FailedXMLRPCResponse() |
217 | { | 273 | { |
218 | Hashtable hash = new Hashtable(); | 274 | Hashtable hash = new Hashtable(); |
diff --git a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs index 1fb0dbc..97e8295 100644 --- a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs +++ b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs | |||
@@ -98,6 +98,7 @@ namespace OpenSim.Server.Handlers.Login | |||
98 | server.AddXmlRPCHandler("login_to_simulator", loginHandlers.HandleXMLRPCLogin, false); | 98 | server.AddXmlRPCHandler("login_to_simulator", loginHandlers.HandleXMLRPCLogin, false); |
99 | server.AddXmlRPCHandler("set_login_level", loginHandlers.HandleXMLRPCSetLoginLevel, false); | 99 | server.AddXmlRPCHandler("set_login_level", loginHandlers.HandleXMLRPCSetLoginLevel, false); |
100 | server.SetDefaultLLSDHandler(loginHandlers.HandleLLSDLogin); | 100 | server.SetDefaultLLSDHandler(loginHandlers.HandleLLSDLogin); |
101 | server.AddWebSocketHandler("/WebSocket/GridLogin", loginHandlers.HandleWebSocketLoginEvents); | ||
101 | } | 102 | } |
102 | } | 103 | } |
103 | } | 104 | } |