aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/GridServer.Modules/GridMessagingModule.cs
diff options
context:
space:
mode:
authorMW2009-02-24 15:57:25 +0000
committerMW2009-02-24 15:57:25 +0000
commit021225675f0d1f28daf6c21fe54b4172c7084036 (patch)
tree0c2cd006e07c82ff11ea9277c397067857767c5d /OpenSim/Grid/GridServer.Modules/GridMessagingModule.cs
parentFirst step in separating out the Userserver console command handling to a "mo... (diff)
downloadopensim-SC-021225675f0d1f28daf6c21fe54b4172c7084036.zip
opensim-SC-021225675f0d1f28daf6c21fe54b4172c7084036.tar.gz
opensim-SC-021225675f0d1f28daf6c21fe54b4172c7084036.tar.bz2
opensim-SC-021225675f0d1f28daf6c21fe54b4172c7084036.tar.xz
Added OpenSim.Grid.GridServer.Modules, for the GridServer modules/components.
Diffstat (limited to 'OpenSim/Grid/GridServer.Modules/GridMessagingModule.cs')
-rw-r--r--OpenSim/Grid/GridServer.Modules/GridMessagingModule.cs161
1 files changed, 161 insertions, 0 deletions
diff --git a/OpenSim/Grid/GridServer.Modules/GridMessagingModule.cs b/OpenSim/Grid/GridServer.Modules/GridMessagingModule.cs
new file mode 100644
index 0000000..9c2b5ca
--- /dev/null
+++ b/OpenSim/Grid/GridServer.Modules/GridMessagingModule.cs
@@ -0,0 +1,161 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using System.Text;
33using Nwc.XmlRpc;
34using log4net;
35using OpenSim.Framework.Servers;
36using OpenSim.Framework;
37using OpenSim.Grid.Framework;
38
39namespace OpenSim.Grid.GridServer.Modules
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}