diff options
Diffstat (limited to 'OpenSim/Grid/GridServer/GridMessagingModule.cs')
-rw-r--r-- | OpenSim/Grid/GridServer/GridMessagingModule.cs | 161 |
1 files changed, 0 insertions, 161 deletions
diff --git a/OpenSim/Grid/GridServer/GridMessagingModule.cs b/OpenSim/Grid/GridServer/GridMessagingModule.cs deleted file mode 100644 index 7194ba4..0000000 --- a/OpenSim/Grid/GridServer/GridMessagingModule.cs +++ /dev/null | |||
@@ -1,161 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using System.Text; | ||
33 | using Nwc.XmlRpc; | ||
34 | using log4net; | ||
35 | using OpenSim.Framework.Servers; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Grid.Framework; | ||
38 | |||
39 | namespace OpenSim.Grid.GridServer | ||
40 | { | ||
41 | public class GridMessagingModule : IGridMessagingMapper | ||
42 | { | ||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
45 | protected GridDBService m_gridDBService; | ||
46 | protected IUGAIMCore m_gridCore; | ||
47 | |||
48 | protected GridConfig m_config; | ||
49 | |||
50 | /// <value> | ||
51 | /// Used to notify old regions as to which OpenSim version to upgrade to | ||
52 | /// </value> | ||
53 | private string m_opensimVersion; | ||
54 | |||
55 | protected BaseHttpServer m_httpServer; | ||
56 | |||
57 | // This is here so that the grid server can hand out MessageServer settings to regions on registration | ||
58 | private List<MessageServerInfo> m_messageServers = new List<MessageServerInfo>(); | ||
59 | |||
60 | public GridMessagingModule() | ||
61 | { | ||
62 | } | ||
63 | |||
64 | public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config) | ||
65 | { | ||
66 | m_opensimVersion = opensimVersion; | ||
67 | m_gridDBService = gridDBService; | ||
68 | m_gridCore = gridCore; | ||
69 | m_config = config; | ||
70 | |||
71 | m_gridCore.RegisterInterface<IGridMessagingMapper>(this); | ||
72 | |||
73 | RegisterHandlers(); | ||
74 | } | ||
75 | |||
76 | public void PostInitialise() | ||
77 | { | ||
78 | |||
79 | } | ||
80 | |||
81 | public void RegisterHandlers() | ||
82 | { | ||
83 | //have these in separate method as some servers restart the http server and reregister all the handlers. | ||
84 | m_httpServer = m_gridCore.GetHttpServer(); | ||
85 | |||
86 | // Message Server ---> Grid Server | ||
87 | m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer); | ||
88 | m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer); | ||
89 | } | ||
90 | |||
91 | public List<MessageServerInfo> GetMessageServersList() | ||
92 | { | ||
93 | lock (m_messageServers) | ||
94 | { | ||
95 | return new List<MessageServerInfo>(m_messageServers); | ||
96 | } | ||
97 | } | ||
98 | |||
99 | public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request) | ||
100 | { | ||
101 | XmlRpcResponse response = new XmlRpcResponse(); | ||
102 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
103 | Hashtable responseData = new Hashtable(); | ||
104 | |||
105 | if (requestData.Contains("uri")) | ||
106 | { | ||
107 | string URI = (string)requestData["URI"]; | ||
108 | string sendkey = (string)requestData["sendkey"]; | ||
109 | string recvkey = (string)requestData["recvkey"]; | ||
110 | MessageServerInfo m = new MessageServerInfo(); | ||
111 | m.URI = URI; | ||
112 | m.sendkey = sendkey; | ||
113 | m.recvkey = recvkey; | ||
114 | RegisterMessageServer(m); | ||
115 | responseData["responsestring"] = "TRUE"; | ||
116 | response.Value = responseData; | ||
117 | } | ||
118 | return response; | ||
119 | } | ||
120 | |||
121 | public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request) | ||
122 | { | ||
123 | XmlRpcResponse response = new XmlRpcResponse(); | ||
124 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
125 | Hashtable responseData = new Hashtable(); | ||
126 | |||
127 | if (requestData.Contains("uri")) | ||
128 | { | ||
129 | string URI = (string)requestData["uri"]; | ||
130 | string sendkey = (string)requestData["sendkey"]; | ||
131 | string recvkey = (string)requestData["recvkey"]; | ||
132 | MessageServerInfo m = new MessageServerInfo(); | ||
133 | m.URI = URI; | ||
134 | m.sendkey = sendkey; | ||
135 | m.recvkey = recvkey; | ||
136 | DeRegisterMessageServer(m); | ||
137 | responseData["responsestring"] = "TRUE"; | ||
138 | response.Value = responseData; | ||
139 | } | ||
140 | return response; | ||
141 | } | ||
142 | |||
143 | public void RegisterMessageServer(MessageServerInfo m) | ||
144 | { | ||
145 | lock (m_messageServers) | ||
146 | { | ||
147 | if (!m_messageServers.Contains(m)) | ||
148 | m_messageServers.Add(m); | ||
149 | } | ||
150 | } | ||
151 | |||
152 | public void DeRegisterMessageServer(MessageServerInfo m) | ||
153 | { | ||
154 | lock (m_messageServers) | ||
155 | { | ||
156 | if (m_messageServers.Contains(m)) | ||
157 | m_messageServers.Remove(m); | ||
158 | } | ||
159 | } | ||
160 | } | ||
161 | } | ||