diff options
Diffstat (limited to 'OpenSim/Grid/MessagingServer.Modules/InterMessageUserServerModule.cs')
-rw-r--r-- | OpenSim/Grid/MessagingServer.Modules/InterMessageUserServerModule.cs | 187 |
1 files changed, 0 insertions, 187 deletions
diff --git a/OpenSim/Grid/MessagingServer.Modules/InterMessageUserServerModule.cs b/OpenSim/Grid/MessagingServer.Modules/InterMessageUserServerModule.cs deleted file mode 100644 index ae04535..0000000 --- a/OpenSim/Grid/MessagingServer.Modules/InterMessageUserServerModule.cs +++ /dev/null | |||
@@ -1,187 +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 OpenSimulator 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.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Threading; | ||
34 | using System.Timers; | ||
35 | using log4net; | ||
36 | using Nwc.XmlRpc; | ||
37 | using OpenMetaverse; | ||
38 | using OpenSim.Data; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Grid.Framework; | ||
41 | using Timer = System.Timers.Timer; | ||
42 | |||
43 | namespace OpenSim.Grid.MessagingServer.Modules | ||
44 | { | ||
45 | public class InterMessageUserServerModule : IInterServiceUserService | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private MessageServerConfig m_cfg; | ||
50 | |||
51 | private IGridServiceCore m_messageCore; | ||
52 | |||
53 | private Timer reconnectTimer = new Timer(300000); // 5 mins | ||
54 | |||
55 | public InterMessageUserServerModule(MessageServerConfig config, IGridServiceCore messageCore) | ||
56 | { | ||
57 | m_cfg = config; | ||
58 | m_messageCore = messageCore; | ||
59 | |||
60 | reconnectTimer.Elapsed += registerWithUserServer; | ||
61 | lock (reconnectTimer) | ||
62 | reconnectTimer.Start(); | ||
63 | } | ||
64 | |||
65 | public void Initialise() | ||
66 | { | ||
67 | m_messageCore.RegisterInterface<IInterServiceUserService>(this); | ||
68 | } | ||
69 | |||
70 | public void PostInitialise() | ||
71 | { | ||
72 | |||
73 | } | ||
74 | |||
75 | public void RegisterHandlers() | ||
76 | { | ||
77 | //have these in separate method as some servers restart the http server and reregister all the handlers. | ||
78 | |||
79 | } | ||
80 | |||
81 | public void registerWithUserServer(object sender, ElapsedEventArgs e) | ||
82 | { | ||
83 | registerWithUserServer(); | ||
84 | } | ||
85 | |||
86 | public bool registerWithUserServer() | ||
87 | { | ||
88 | Hashtable UserParams = new Hashtable(); | ||
89 | // Login / Authentication | ||
90 | |||
91 | if (m_cfg.HttpSSL) | ||
92 | { | ||
93 | UserParams["uri"] = "https://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; | ||
94 | } | ||
95 | else | ||
96 | { | ||
97 | UserParams["uri"] = "http://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; | ||
98 | } | ||
99 | |||
100 | UserParams["recvkey"] = m_cfg.UserRecvKey; | ||
101 | UserParams["sendkey"] = m_cfg.UserRecvKey; | ||
102 | |||
103 | // Package into an XMLRPC Request | ||
104 | ArrayList SendParams = new ArrayList(); | ||
105 | SendParams.Add(UserParams); | ||
106 | |||
107 | bool success = true; | ||
108 | string[] servers = m_cfg.UserServerURL.Split(' '); | ||
109 | |||
110 | foreach (string srv in servers) | ||
111 | { | ||
112 | // Send Request | ||
113 | try | ||
114 | { | ||
115 | XmlRpcRequest UserReq = new XmlRpcRequest("register_messageserver", SendParams); | ||
116 | XmlRpcResponse UserResp = UserReq.Send(srv, 16000); | ||
117 | |||
118 | // Process Response | ||
119 | Hashtable GridRespData = (Hashtable)UserResp.Value; | ||
120 | // if we got a response, we were successful | ||
121 | if (!GridRespData.ContainsKey("responsestring")) | ||
122 | success = false; | ||
123 | else | ||
124 | m_log.InfoFormat("[SERVER] Registered with {0}", srv); | ||
125 | } | ||
126 | catch | ||
127 | { | ||
128 | m_log.ErrorFormat("Unable to connect to server {0}. Server not running?", srv); | ||
129 | success = false; | ||
130 | } | ||
131 | } | ||
132 | return success; | ||
133 | } | ||
134 | |||
135 | public bool deregisterWithUserServer() | ||
136 | { | ||
137 | Hashtable request = new Hashtable(); | ||
138 | |||
139 | return SendToUserServer(request, "deregister_messageserver"); | ||
140 | } | ||
141 | |||
142 | public bool SendToUserServer(Hashtable request, string method) | ||
143 | { | ||
144 | // Login / Authentication | ||
145 | |||
146 | if (m_cfg.HttpSSL) | ||
147 | { | ||
148 | request["uri"] = "https://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; | ||
149 | } | ||
150 | else | ||
151 | { | ||
152 | request["uri"] = "http://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; | ||
153 | } | ||
154 | |||
155 | request["recvkey"] = m_cfg.UserRecvKey; | ||
156 | request["sendkey"] = m_cfg.UserRecvKey; | ||
157 | |||
158 | // Package into an XMLRPC Request | ||
159 | ArrayList SendParams = new ArrayList(); | ||
160 | SendParams.Add(request); | ||
161 | |||
162 | bool success = true; | ||
163 | string[] servers = m_cfg.UserServerURL.Split(' '); | ||
164 | |||
165 | // Send Request | ||
166 | foreach (string srv in servers) | ||
167 | { | ||
168 | try | ||
169 | { | ||
170 | XmlRpcRequest UserReq = new XmlRpcRequest(method, SendParams); | ||
171 | XmlRpcResponse UserResp = UserReq.Send(m_cfg.UserServerURL, 16000); | ||
172 | // Process Response | ||
173 | Hashtable UserRespData = (Hashtable)UserResp.Value; | ||
174 | // if we got a response, we were successful | ||
175 | if (!UserRespData.ContainsKey("responsestring")) | ||
176 | success = false; | ||
177 | } | ||
178 | catch | ||
179 | { | ||
180 | m_log.ErrorFormat("Unable to connect to server {0}. Server not running?", srv); | ||
181 | success = false; | ||
182 | } | ||
183 | } | ||
184 | return success; | ||
185 | } | ||
186 | } | ||
187 | } | ||