aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/MessagingServer.Modules/MessageUserServerModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/MessagingServer.Modules/MessageUserServerModule.cs')
-rw-r--r--OpenSim/Grid/MessagingServer.Modules/MessageUserServerModule.cs372
1 files changed, 186 insertions, 186 deletions
diff --git a/OpenSim/Grid/MessagingServer.Modules/MessageUserServerModule.cs b/OpenSim/Grid/MessagingServer.Modules/MessageUserServerModule.cs
index 9293b3e..e153c39 100644
--- a/OpenSim/Grid/MessagingServer.Modules/MessageUserServerModule.cs
+++ b/OpenSim/Grid/MessagingServer.Modules/MessageUserServerModule.cs
@@ -1,186 +1,186 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Net; 31using System.Net;
32using System.Reflection; 32using System.Reflection;
33using System.Threading; 33using System.Threading;
34using System.Timers; 34using System.Timers;
35using log4net; 35using log4net;
36using Nwc.XmlRpc; 36using Nwc.XmlRpc;
37using OpenMetaverse; 37using OpenMetaverse;
38using OpenSim.Data; 38using OpenSim.Data;
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Grid.Framework; 40using OpenSim.Grid.Framework;
41using Timer = System.Timers.Timer; 41using Timer = System.Timers.Timer;
42 42
43namespace OpenSim.Grid.MessagingServer.Modules 43namespace OpenSim.Grid.MessagingServer.Modules
44{ 44{
45 public class MessageUserServerModule : IMessageUserServerService 45 public class MessageUserServerModule : IMessageUserServerService
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private MessageServerConfig m_cfg; 49 private MessageServerConfig m_cfg;
50 50
51 private IUGAIMCore m_messageCore; 51 private IUGAIMCore m_messageCore;
52 52
53 private Timer reconnectTimer = new Timer(300000); // 5 mins 53 private Timer reconnectTimer = new Timer(300000); // 5 mins
54 54
55 public MessageUserServerModule(MessageServerConfig config, IUGAIMCore messageCore) 55 public MessageUserServerModule(MessageServerConfig config, IUGAIMCore messageCore)
56 { 56 {
57 m_cfg = config; 57 m_cfg = config;
58 m_messageCore = messageCore; 58 m_messageCore = messageCore;
59 59
60 reconnectTimer.Elapsed += registerWithUserServer; 60 reconnectTimer.Elapsed += registerWithUserServer;
61 reconnectTimer.Start(); 61 reconnectTimer.Start();
62 } 62 }
63 63
64 public void Initialise() 64 public void Initialise()
65 { 65 {
66 m_messageCore.RegisterInterface<IMessageUserServerService>(this); 66 m_messageCore.RegisterInterface<IMessageUserServerService>(this);
67 } 67 }
68 68
69 public void PostInitialise() 69 public void PostInitialise()
70 { 70 {
71 71
72 } 72 }
73 73
74 public void RegisterHandlers() 74 public void RegisterHandlers()
75 { 75 {
76 //have these in separate method as some servers restart the http server and reregister all the handlers. 76 //have these in separate method as some servers restart the http server and reregister all the handlers.
77 77
78 } 78 }
79 79
80 public void registerWithUserServer(object sender, ElapsedEventArgs e) 80 public void registerWithUserServer(object sender, ElapsedEventArgs e)
81 { 81 {
82 registerWithUserServer(); 82 registerWithUserServer();
83 } 83 }
84 84
85 public bool registerWithUserServer() 85 public bool registerWithUserServer()
86 { 86 {
87 Hashtable UserParams = new Hashtable(); 87 Hashtable UserParams = new Hashtable();
88 // Login / Authentication 88 // Login / Authentication
89 89
90 if (m_cfg.HttpSSL) 90 if (m_cfg.HttpSSL)
91 { 91 {
92 UserParams["uri"] = "https://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; 92 UserParams["uri"] = "https://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort;
93 } 93 }
94 else 94 else
95 { 95 {
96 UserParams["uri"] = "http://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; 96 UserParams["uri"] = "http://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort;
97 } 97 }
98 98
99 UserParams["recvkey"] = m_cfg.UserRecvKey; 99 UserParams["recvkey"] = m_cfg.UserRecvKey;
100 UserParams["sendkey"] = m_cfg.UserRecvKey; 100 UserParams["sendkey"] = m_cfg.UserRecvKey;
101 101
102 // Package into an XMLRPC Request 102 // Package into an XMLRPC Request
103 ArrayList SendParams = new ArrayList(); 103 ArrayList SendParams = new ArrayList();
104 SendParams.Add(UserParams); 104 SendParams.Add(UserParams);
105 105
106 bool success = true; 106 bool success = true;
107 string[] servers = m_cfg.UserServerURL.Split(' '); 107 string[] servers = m_cfg.UserServerURL.Split(' ');
108 108
109 foreach (string srv in servers) 109 foreach (string srv in servers)
110 { 110 {
111 // Send Request 111 // Send Request
112 try 112 try
113 { 113 {
114 XmlRpcRequest UserReq = new XmlRpcRequest("register_messageserver", SendParams); 114 XmlRpcRequest UserReq = new XmlRpcRequest("register_messageserver", SendParams);
115 XmlRpcResponse UserResp = UserReq.Send(srv, 16000); 115 XmlRpcResponse UserResp = UserReq.Send(srv, 16000);
116 116
117 // Process Response 117 // Process Response
118 Hashtable GridRespData = (Hashtable)UserResp.Value; 118 Hashtable GridRespData = (Hashtable)UserResp.Value;
119 // if we got a response, we were successful 119 // if we got a response, we were successful
120 if (!GridRespData.ContainsKey("responsestring")) 120 if (!GridRespData.ContainsKey("responsestring"))
121 success = false; 121 success = false;
122 else 122 else
123 m_log.InfoFormat("[SERVER] Registered with {0}", srv); 123 m_log.InfoFormat("[SERVER] Registered with {0}", srv);
124 } 124 }
125 catch 125 catch
126 { 126 {
127 m_log.ErrorFormat("Unable to connect to server {0}. Server not running?", srv); 127 m_log.ErrorFormat("Unable to connect to server {0}. Server not running?", srv);
128 success = false; 128 success = false;
129 } 129 }
130 } 130 }
131 return success; 131 return success;
132 } 132 }
133 133
134 public bool deregisterWithUserServer() 134 public bool deregisterWithUserServer()
135 { 135 {
136 Hashtable request = new Hashtable(); 136 Hashtable request = new Hashtable();
137 137
138 return SendToUserServer(request, "deregister_messageserver"); 138 return SendToUserServer(request, "deregister_messageserver");
139 } 139 }
140 140
141 public bool SendToUserServer(Hashtable request, string method) 141 public bool SendToUserServer(Hashtable request, string method)
142 { 142 {
143 // Login / Authentication 143 // Login / Authentication
144 144
145 if (m_cfg.HttpSSL) 145 if (m_cfg.HttpSSL)
146 { 146 {
147 request["uri"] = "https://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; 147 request["uri"] = "https://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort;
148 } 148 }
149 else 149 else
150 { 150 {
151 request["uri"] = "http://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; 151 request["uri"] = "http://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort;
152 } 152 }
153 153
154 request["recvkey"] = m_cfg.UserRecvKey; 154 request["recvkey"] = m_cfg.UserRecvKey;
155 request["sendkey"] = m_cfg.UserRecvKey; 155 request["sendkey"] = m_cfg.UserRecvKey;
156 156
157 // Package into an XMLRPC Request 157 // Package into an XMLRPC Request
158 ArrayList SendParams = new ArrayList(); 158 ArrayList SendParams = new ArrayList();
159 SendParams.Add(request); 159 SendParams.Add(request);
160 160
161 bool success = true; 161 bool success = true;
162 string[] servers = m_cfg.UserServerURL.Split(' '); 162 string[] servers = m_cfg.UserServerURL.Split(' ');
163 163
164 // Send Request 164 // Send Request
165 foreach (string srv in servers) 165 foreach (string srv in servers)
166 { 166 {
167 try 167 try
168 { 168 {
169 XmlRpcRequest UserReq = new XmlRpcRequest(method, SendParams); 169 XmlRpcRequest UserReq = new XmlRpcRequest(method, SendParams);
170 XmlRpcResponse UserResp = UserReq.Send(m_cfg.UserServerURL, 16000); 170 XmlRpcResponse UserResp = UserReq.Send(m_cfg.UserServerURL, 16000);
171 // Process Response 171 // Process Response
172 Hashtable UserRespData = (Hashtable)UserResp.Value; 172 Hashtable UserRespData = (Hashtable)UserResp.Value;
173 // if we got a response, we were successful 173 // if we got a response, we were successful
174 if (!UserRespData.ContainsKey("responsestring")) 174 if (!UserRespData.ContainsKey("responsestring"))
175 success = false; 175 success = false;
176 } 176 }
177 catch 177 catch
178 { 178 {
179 m_log.ErrorFormat("Unable to connect to server {0}. Server not running?", srv); 179 m_log.ErrorFormat("Unable to connect to server {0}. Server not running?", srv);
180 success = false; 180 success = false;
181 } 181 }
182 } 182 }
183 return success; 183 return success;
184 } 184 }
185 } 185 }
186} 186}