aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer/MessageServersConnector.cs
diff options
context:
space:
mode:
authorTeravus Ovares2008-01-06 18:18:19 +0000
committerTeravus Ovares2008-01-06 18:18:19 +0000
commitb8efd5f2949dd247590c1e40509e71031faf3413 (patch)
tree02307ef3edef08bf1a393d89cd772ad8d0ee7ae5 /OpenSim/Grid/UserServer/MessageServersConnector.cs
parentSet svn:eol-style. (diff)
downloadopensim-SC_OLD-b8efd5f2949dd247590c1e40509e71031faf3413.zip
opensim-SC_OLD-b8efd5f2949dd247590c1e40509e71031faf3413.tar.gz
opensim-SC_OLD-b8efd5f2949dd247590c1e40509e71031faf3413.tar.bz2
opensim-SC_OLD-b8efd5f2949dd247590c1e40509e71031faf3413.tar.xz
* Added some userserver glue for communications with the message server
* Added some code for the message server, fixed a few references and starting to flesh it out.
Diffstat (limited to 'OpenSim/Grid/UserServer/MessageServersConnector.cs')
-rw-r--r--OpenSim/Grid/UserServer/MessageServersConnector.cs157
1 files changed, 157 insertions, 0 deletions
diff --git a/OpenSim/Grid/UserServer/MessageServersConnector.cs b/OpenSim/Grid/UserServer/MessageServersConnector.cs
new file mode 100644
index 0000000..deec739
--- /dev/null
+++ b/OpenSim/Grid/UserServer/MessageServersConnector.cs
@@ -0,0 +1,157 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Text;
5using System.Threading;
6using libsecondlife;
7using Nwc.XmlRpc;
8using OpenSim.Framework;
9using OpenSim.Framework.Communications.Cache;
10using OpenSim.Framework.Console;
11using OpenSim.Framework.Servers;
12
13namespace OpenSim.Grid.UserServer
14{
15
16 public class MessageServersConnector
17 {
18 private LogBase m_log;
19 public Dictionary<string, MessageServerInfo> MessageServers;
20
21 public MessageServersConnector(LogBase log)
22 {
23 m_log=log;
24 MessageServers = new Dictionary<string, MessageServerInfo>();
25 }
26
27 public void RegisterMessageServer(string URI, MessageServerInfo serverData)
28 {
29 MessageServers.Add(URI, serverData);
30 }
31
32 public void DeRegisterMessageServer(string URI)
33 {
34 MessageServers.Remove(URI);
35 }
36
37 public void AddResponsibleRegion(string URI, ulong regionhandle)
38 {
39 if (!MessageServers.ContainsKey(URI))
40 {
41 m_log.Warn("MSGSERVER", "Got addResponsibleRegion Request for a MessageServer that isn't registered");
42 }
43 else
44 {
45 MessageServerInfo msginfo = MessageServers["URI"];
46 msginfo.responsibleForRegions.Add(regionhandle);
47 MessageServers["URI"] = msginfo;
48 }
49 }
50 public void RemoveResponsibleRegion(string URI, ulong regionhandle)
51 {
52 if (!MessageServers.ContainsKey(URI))
53 {
54 m_log.Warn("MSGSERVER", "Got RemoveResponsibleRegion Request for a MessageServer that isn't registered");
55 }
56 else
57 {
58 MessageServerInfo msginfo = MessageServers["URI"];
59 if (msginfo.responsibleForRegions.Contains(regionhandle))
60 {
61 msginfo.responsibleForRegions.Remove(regionhandle);
62 MessageServers["URI"] = msginfo;
63 }
64 }
65
66 }
67 public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request)
68 {
69 XmlRpcResponse response = new XmlRpcResponse();
70 Hashtable requestData = (Hashtable)request.Params[0];
71 Hashtable responseData = new Hashtable();
72
73 if (requestData.Contains("uri"))
74 {
75 string URI = (string)requestData["URI"];
76 string sendkey=(string)requestData["sendkey"];
77 string recvkey=(string)requestData["recvkey"];
78 MessageServerInfo m = new MessageServerInfo();
79 m.URI = URI;
80 m.sendkey = sendkey;
81 m.recvkey = recvkey;
82 RegisterMessageServer(URI, m);
83 responseData["responsestring"] = "TRUE";
84 response.Value = responseData;
85 }
86 return response;
87 }
88 public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request)
89 {
90 XmlRpcResponse response = new XmlRpcResponse();
91 Hashtable requestData = (Hashtable)request.Params[0];
92 Hashtable responseData = new Hashtable();
93
94 if (requestData.Contains("uri"))
95 {
96 string URI = (string)requestData["URI"];
97
98 DeRegisterMessageServer(URI);
99 responseData["responsestring"] = "TRUE";
100 response.Value = responseData;
101 }
102 return response;
103 }
104 public XmlRpcResponse XmlRPCUserMovedtoRegion(XmlRpcRequest request)
105 {
106 XmlRpcResponse response = new XmlRpcResponse();
107 Hashtable requestData = (Hashtable)request.Params[0];
108 Hashtable responseData = new Hashtable();
109
110 if (requestData.Contains("fromuri"))
111 {
112 string sURI = (string)requestData["fromuri"];
113 string sagentID = (string)requestData["agentid"];
114 string ssessionID = (string)requestData["sessionid"];
115 string scurrentRegionID = (string)requestData["regionid"];
116 string sregionhandle = (string)requestData["regionhandle"];
117 string scurrentpos = (string)requestData["currentpos"];
118 //LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos);
119 // TODO: Okay now raise event so the user server can pass this data to the Usermanager
120
121 responseData["responsestring"] = "TRUE";
122 response.Value = responseData;
123 }
124 return response;
125 }
126
127 public void TellMessageServersAboutUser(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position)
128 {
129 // Loop over registered Message Servers ( AND THERE WILL BE MORE THEN ONE :D )
130 foreach (MessageServerInfo serv in MessageServers.Values)
131 {
132 NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID, regionhandle, Position);
133 }
134 }
135
136 private void NotifyMessageServerAboutUser(MessageServerInfo serv, LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position)
137 {
138 Hashtable reqparams = new Hashtable();
139 reqparams["sendkey"] = serv.sendkey;
140 reqparams["agentid"] = agentID.ToString();
141 reqparams["sessionid"] = sessionID.ToString();
142 reqparams["regionid"] = RegionID.ToString();
143 reqparams["regionhandle"] = regionhandle.ToString();
144 reqparams["position"] = Position.ToString();
145
146 ArrayList SendParams = new ArrayList();
147 SendParams.Add(reqparams);
148
149 XmlRpcRequest GridReq = new XmlRpcRequest("user_login", SendParams);
150 XmlRpcResponse GridResp = GridReq.Send(serv.URI, 6000);
151 m_log.Verbose("LOGIN","Notified : " + serv.URI + " about user login");
152
153 }
154
155
156 }
157}