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