aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/Connectors')
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs58
-rw-r--r--OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs129
2 files changed, 187 insertions, 0 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 265bacf..50036b3 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -560,6 +560,64 @@ namespace OpenSim.Services.Connectors.Hypergrid
560 return serverURLs; 560 return serverURLs;
561 } 561 }
562 562
563 public string LocateUser(UUID userID)
564 {
565 Hashtable hash = new Hashtable();
566 hash["userID"] = userID.ToString();
567
568 IList paramList = new ArrayList();
569 paramList.Add(hash);
570
571 XmlRpcRequest request = new XmlRpcRequest("locate_user", paramList);
572 string reason = string.Empty;
573
574 // Send and get reply
575 string url = string.Empty;
576 XmlRpcResponse response = null;
577 try
578 {
579 response = request.Send(m_ServerURL, 10000);
580 }
581 catch (Exception e)
582 {
583 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL);
584 reason = "Exception: " + e.Message;
585 return url;
586 }
587
588 if (response.IsFault)
589 {
590 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString);
591 reason = "XMLRPC Fault";
592 return url;
593 }
594
595 hash = (Hashtable)response.Value;
596 //foreach (Object o in hash)
597 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
598 try
599 {
600 if (hash == null)
601 {
602 m_log.ErrorFormat("[USER AGENT CONNECTOR]: LocateUser Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
603 reason = "Internal error 1";
604 return url;
605 }
606
607 // Here's the actual response
608 if (hash.ContainsKey("URL"))
609 url = hash["URL"].ToString();
610
611 }
612 catch (Exception e)
613 {
614 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response.");
615 reason = "Exception: " + e.Message;
616 }
617
618 return url;
619 }
620
563 private bool GetBoolResponse(XmlRpcRequest request, out string reason) 621 private bool GetBoolResponse(XmlRpcRequest request, out string reason)
564 { 622 {
565 //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURL); 623 //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURL);
diff --git a/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs
new file mode 100644
index 0000000..65ee7c7
--- /dev/null
+++ b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs
@@ -0,0 +1,129 @@
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 */
27using System;
28using System.Collections;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32
33using OpenMetaverse;
34using Nwc.XmlRpc;
35using log4net;
36
37using OpenSim.Framework;
38
39namespace OpenSim.Services.Connectors.InstantMessage
40{
41 public class InstantMessageServiceConnector
42 {
43 private static readonly ILog m_log =
44 LogManager.GetLogger(
45 MethodBase.GetCurrentMethod().DeclaringType);
46
47 /// <summary>
48 /// This actually does the XMLRPC Request
49 /// </summary>
50 /// <param name="url">URL we pull the data out of to send the request to</param>
51 /// <param name="im">The Instant Message </param>
52 /// <returns>Bool if the message was successfully delivered at the other side.</returns>
53 public static bool SendInstantMessage(string url, GridInstantMessage im)
54 {
55 Hashtable xmlrpcdata = ConvertGridInstantMessageToXMLRPC(im);
56 xmlrpcdata["region_handle"] = 0;
57
58 ArrayList SendParams = new ArrayList();
59 SendParams.Add(xmlrpcdata);
60 XmlRpcRequest GridReq = new XmlRpcRequest("grid_instant_message", SendParams);
61 try
62 {
63
64 XmlRpcResponse GridResp = GridReq.Send(url, 3000);
65
66 Hashtable responseData = (Hashtable)GridResp.Value;
67
68 if (responseData.ContainsKey("success"))
69 {
70 if ((string)responseData["success"] == "TRUE")
71 {
72 m_log.DebugFormat("[XXX] Success");
73 return true;
74 }
75 else
76 {
77 m_log.DebugFormat("[XXX] Fail");
78 return false;
79 }
80 }
81 else
82 {
83 return false;
84 }
85 }
86 catch (WebException e)
87 {
88 m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to {0} the host didn't respond " + e.ToString(), url);
89 }
90
91 return false;
92 }
93
94 /// <summary>
95 /// Takes a GridInstantMessage and converts it into a Hashtable for XMLRPC
96 /// </summary>
97 /// <param name="msg">The GridInstantMessage object</param>
98 /// <returns>Hashtable containing the XMLRPC request</returns>
99 protected static Hashtable ConvertGridInstantMessageToXMLRPC(GridInstantMessage msg)
100 {
101 Hashtable gim = new Hashtable();
102 gim["from_agent_id"] = msg.fromAgentID.ToString();
103 // Kept for compatibility
104 gim["from_agent_session"] = UUID.Zero.ToString();
105 gim["to_agent_id"] = msg.toAgentID.ToString();
106 gim["im_session_id"] = msg.imSessionID.ToString();
107 gim["timestamp"] = msg.timestamp.ToString();
108 gim["from_agent_name"] = msg.fromAgentName;
109 gim["message"] = msg.message;
110 byte[] dialogdata = new byte[1]; dialogdata[0] = msg.dialog;
111 gim["dialog"] = Convert.ToBase64String(dialogdata, Base64FormattingOptions.None);
112
113 if (msg.fromGroup)
114 gim["from_group"] = "TRUE";
115 else
116 gim["from_group"] = "FALSE";
117 byte[] offlinedata = new byte[1]; offlinedata[0] = msg.offline;
118 gim["offline"] = Convert.ToBase64String(offlinedata, Base64FormattingOptions.None);
119 gim["parent_estate_id"] = msg.ParentEstateID.ToString();
120 gim["position_x"] = msg.Position.X.ToString();
121 gim["position_y"] = msg.Position.Y.ToString();
122 gim["position_z"] = msg.Position.Z.ToString();
123 gim["region_id"] = msg.RegionID.ToString();
124 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket, Base64FormattingOptions.None);
125 return gim;
126 }
127
128 }
129}