29 using System.Collections;
30 using System.Collections.Generic;
32 using System.Reflection;
35 using OpenSim.Framework;
36 using OpenSim.Server.Base;
37 using OpenSim.Services.Interfaces;
38 using OpenSim.Framework.Servers.HttpServer;
39 using OpenSim.Server.Handlers.Base;
46 namespace OpenSim.Server.Handlers.Hypergrid
50 private static readonly ILog m_log =
52 MethodBase.GetCurrentMethod().DeclaringType);
67 base(config, server, String.Empty)
69 IConfig gridConfig = config.Configs[
"HGInstantMessageService"];
70 if (gridConfig != null)
72 string serviceDll = gridConfig.GetString(
"LocalServiceModule", string.Empty);
74 Object[] args =
new Object[] { config, simConnector };
75 m_IMService = ServerUtils.LoadPlugin<
IInstantMessage>(serviceDll, args);
77 if (m_IMService == null)
78 throw new Exception(
"InstantMessage server connector cannot proceed because of missing service");
80 server.AddXmlRPCHandler(
"grid_instant_message", ProcessInstantMessage,
false);
91 bool successful =
false;
96 UUID fromAgentID = UUID.Zero;
97 UUID toAgentID = UUID.Zero;
98 UUID imSessionID = UUID.Zero;
100 string fromAgentName =
"";
102 byte dialog = (byte)0;
103 bool fromGroup =
false;
104 byte offline = (byte)0;
105 uint ParentEstateID = 0;
107 UUID RegionID = UUID.Zero;
108 byte[] binaryBucket =
new byte[0];
116 Hashtable requestData = (Hashtable)request.Params[0];
118 if (requestData.ContainsKey(
"from_agent_id")
119 && requestData.ContainsKey(
"to_agent_id") && requestData.ContainsKey(
"im_session_id")
120 && requestData.ContainsKey(
"timestamp") && requestData.ContainsKey(
"from_agent_name")
121 && requestData.ContainsKey(
"message") && requestData.ContainsKey(
"dialog")
122 && requestData.ContainsKey(
"from_group")
123 && requestData.ContainsKey(
"offline") && requestData.ContainsKey(
"parent_estate_id")
124 && requestData.ContainsKey(
"position_x") && requestData.ContainsKey(
"position_y")
125 && requestData.ContainsKey(
"position_z") && requestData.ContainsKey(
"region_id")
126 && requestData.ContainsKey(
"binary_bucket"))
129 UUID.TryParse((string)requestData[
"from_agent_id"], out fromAgentID);
130 UUID.TryParse((string)requestData[
"to_agent_id"], out toAgentID);
131 UUID.TryParse((string)requestData[
"im_session_id"], out imSessionID);
132 UUID.TryParse((string)requestData[
"region_id"], out RegionID);
135 timestamp = (uint)Convert.ToInt32((
string)requestData[
"timestamp"]);
137 catch (ArgumentException)
140 catch (FormatException)
143 catch (OverflowException)
147 fromAgentName = (string)requestData[
"from_agent_name"];
148 message = (string)requestData[
"message"];
150 message = string.Empty;
153 string requestData1 = (string)requestData[
"dialog"];
154 if (
string.IsNullOrEmpty(requestData1))
160 byte[] dialogdata = Convert.FromBase64String(requestData1);
161 dialog = dialogdata[0];
164 if ((
string)requestData[
"from_group"] ==
"TRUE")
167 string requestData2 = (string)requestData[
"offline"];
168 if (String.IsNullOrEmpty(requestData2))
174 byte[] offlinedata = Convert.FromBase64String(requestData2);
175 offline = offlinedata[0];
180 ParentEstateID = (uint)Convert.ToInt32((
string)requestData[
"parent_estate_id"]);
182 catch (ArgumentException)
185 catch (FormatException)
188 catch (OverflowException)
192 float.TryParse((string)requestData[
"position_x"], out pos_x);
193 float.TryParse((string)requestData[
"position_y"], out pos_y);
194 float.TryParse((string)requestData[
"position_z"], out pos_z);
196 Position =
new Vector3(pos_x, pos_y, pos_z);
198 string requestData3 = (string)requestData[
"binary_bucket"];
199 if (
string.IsNullOrEmpty(requestData3))
201 binaryBucket =
new byte[0];
205 binaryBucket = Convert.FromBase64String(requestData3);
210 gim.fromAgentID = fromAgentID.Guid;
211 gim.fromAgentName = fromAgentName;
212 gim.fromGroup = fromGroup;
213 gim.imSessionID = imSessionID.Guid;
214 gim.RegionID = RegionID.Guid;
215 gim.timestamp = timestamp;
216 gim.toAgentID = toAgentID.Guid;
217 gim.message = message;
219 gim.offline = offline;
220 gim.ParentEstateID = ParentEstateID;
221 gim.Position = Position;
222 gim.binaryBucket = binaryBucket;
224 successful = m_IMService.IncomingInstantMessage(gim);
230 m_log.Error(
"[INSTANT MESSAGE]: Caught unexpected exception:", e);
236 XmlRpcResponse resp =
new XmlRpcResponse();
237 Hashtable respdata =
new Hashtable();
239 respdata[
"success"] =
"TRUE";
241 respdata[
"success"] =
"FALSE";
242 resp.Value = respdata;
virtual XmlRpcResponse ProcessInstantMessage(XmlRpcRequest request, IPEndPoint remoteClient)
OpenSim.Services.Interfaces.GridRegion GridRegion
Interface to OpenSimulator's built in HTTP server. Use this to register handlers (http, llsd, xmlrpc, etc.) for given URLs.
InstantMessageServerConnector(IConfigSource config, IHttpServer server, string configName)
IInstantMessage GetService()
InstantMessageServerConnector(IConfigSource config, IHttpServer server)
InstantMessageServerConnector(IConfigSource config, IHttpServer server, IInstantMessageSimConnector simConnector)