diff options
Diffstat (limited to 'OpenSim/Services/Connectors')
7 files changed, 926 insertions, 29 deletions
diff --git a/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs index 861c475..c5ae0c0 100644 --- a/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs +++ b/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs | |||
@@ -38,7 +38,7 @@ using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; | |||
38 | using OpenSim.Server.Base; | 38 | using OpenSim.Server.Base; |
39 | using OpenMetaverse; | 39 | using OpenMetaverse; |
40 | 40 | ||
41 | namespace OpenSim.Services.Connectors | 41 | namespace OpenSim.Services.Connectors.Friends |
42 | { | 42 | { |
43 | public class FriendsServicesConnector : IFriendsService | 43 | public class FriendsServicesConnector : IFriendsService |
44 | { | 44 | { |
@@ -84,7 +84,7 @@ namespace OpenSim.Services.Connectors | |||
84 | 84 | ||
85 | 85 | ||
86 | #region IFriendsService | 86 | #region IFriendsService |
87 | 87 | ||
88 | public FriendInfo[] GetFriends(UUID PrincipalID) | 88 | public FriendInfo[] GetFriends(UUID PrincipalID) |
89 | { | 89 | { |
90 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | 90 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
@@ -92,6 +92,21 @@ namespace OpenSim.Services.Connectors | |||
92 | sendData["PRINCIPALID"] = PrincipalID.ToString(); | 92 | sendData["PRINCIPALID"] = PrincipalID.ToString(); |
93 | sendData["METHOD"] = "getfriends"; | 93 | sendData["METHOD"] = "getfriends"; |
94 | 94 | ||
95 | return GetFriends(sendData, PrincipalID.ToString()); | ||
96 | } | ||
97 | |||
98 | public FriendInfo[] GetFriends(string PrincipalID) | ||
99 | { | ||
100 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
101 | |||
102 | sendData["PRINCIPALID"] = PrincipalID; | ||
103 | sendData["METHOD"] = "getfriends_string"; | ||
104 | |||
105 | return GetFriends(sendData, PrincipalID); | ||
106 | } | ||
107 | |||
108 | protected FriendInfo[] GetFriends(Dictionary<string, object> sendData, string PrincipalID) | ||
109 | { | ||
95 | string reqString = ServerUtils.BuildQueryString(sendData); | 110 | string reqString = ServerUtils.BuildQueryString(sendData); |
96 | 111 | ||
97 | try | 112 | try |
@@ -144,14 +159,10 @@ namespace OpenSim.Services.Connectors | |||
144 | 159 | ||
145 | } | 160 | } |
146 | 161 | ||
147 | public bool StoreFriend(UUID PrincipalID, string Friend, int flags) | 162 | public bool StoreFriend(string PrincipalID, string Friend, int flags) |
148 | { | 163 | { |
149 | FriendInfo finfo = new FriendInfo(); | ||
150 | finfo.PrincipalID = PrincipalID; | ||
151 | finfo.Friend = Friend; | ||
152 | finfo.MyFlags = flags; | ||
153 | 164 | ||
154 | Dictionary<string, object> sendData = finfo.ToKeyValuePairs(); | 165 | Dictionary<string, object> sendData = ToKeyValuePairs(PrincipalID, Friend, flags); |
155 | 166 | ||
156 | sendData["METHOD"] = "storefriend"; | 167 | sendData["METHOD"] = "storefriend"; |
157 | 168 | ||
@@ -189,6 +200,16 @@ namespace OpenSim.Services.Connectors | |||
189 | 200 | ||
190 | } | 201 | } |
191 | 202 | ||
203 | public bool Delete(string PrincipalID, string Friend) | ||
204 | { | ||
205 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
206 | sendData["PRINCIPALID"] = PrincipalID.ToString(); | ||
207 | sendData["FRIEND"] = Friend; | ||
208 | sendData["METHOD"] = "deletefriend_string"; | ||
209 | |||
210 | return Delete(sendData, PrincipalID, Friend); | ||
211 | } | ||
212 | |||
192 | public bool Delete(UUID PrincipalID, string Friend) | 213 | public bool Delete(UUID PrincipalID, string Friend) |
193 | { | 214 | { |
194 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | 215 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
@@ -196,6 +217,11 @@ namespace OpenSim.Services.Connectors | |||
196 | sendData["FRIEND"] = Friend; | 217 | sendData["FRIEND"] = Friend; |
197 | sendData["METHOD"] = "deletefriend"; | 218 | sendData["METHOD"] = "deletefriend"; |
198 | 219 | ||
220 | return Delete(sendData, PrincipalID.ToString(), Friend); | ||
221 | } | ||
222 | |||
223 | public bool Delete(Dictionary<string, object> sendData, string PrincipalID, string Friend) | ||
224 | { | ||
199 | string reply = string.Empty; | 225 | string reply = string.Empty; |
200 | try | 226 | try |
201 | { | 227 | { |
@@ -230,5 +256,16 @@ namespace OpenSim.Services.Connectors | |||
230 | } | 256 | } |
231 | 257 | ||
232 | #endregion | 258 | #endregion |
259 | |||
260 | public Dictionary<string, object> ToKeyValuePairs(string principalID, string friend, int flags) | ||
261 | { | ||
262 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
263 | result["PrincipalID"] = principalID; | ||
264 | result["Friend"] = friend; | ||
265 | result["MyFlags"] = flags; | ||
266 | |||
267 | return result; | ||
268 | } | ||
269 | |||
233 | } | 270 | } |
234 | } \ No newline at end of file | 271 | } \ No newline at end of file |
diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs new file mode 100644 index 0000000..d699f59 --- /dev/null +++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs | |||
@@ -0,0 +1,206 @@ | |||
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 log4net; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Services.Interfaces; | ||
36 | using OpenSim.Services.Connectors.Friends; | ||
37 | using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; | ||
38 | using OpenSim.Server.Base; | ||
39 | using OpenMetaverse; | ||
40 | |||
41 | namespace OpenSim.Services.Connectors.Hypergrid | ||
42 | { | ||
43 | public class HGFriendsServicesConnector | ||
44 | { | ||
45 | private static readonly ILog m_log = | ||
46 | LogManager.GetLogger( | ||
47 | MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private string m_ServerURI = String.Empty; | ||
50 | private string m_ServiceKey = String.Empty; | ||
51 | private UUID m_SessionID; | ||
52 | |||
53 | public HGFriendsServicesConnector() | ||
54 | { | ||
55 | } | ||
56 | |||
57 | public HGFriendsServicesConnector(string serverURI) | ||
58 | { | ||
59 | m_ServerURI = serverURI.TrimEnd('/'); | ||
60 | } | ||
61 | |||
62 | public HGFriendsServicesConnector(string serverURI, UUID sessionID, string serviceKey) | ||
63 | { | ||
64 | m_ServerURI = serverURI.TrimEnd('/'); | ||
65 | m_ServiceKey = serviceKey; | ||
66 | m_SessionID = sessionID; | ||
67 | } | ||
68 | |||
69 | #region IFriendsService | ||
70 | |||
71 | public uint GetFriendPerms(UUID PrincipalID, UUID friendID) | ||
72 | { | ||
73 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
74 | |||
75 | sendData["PRINCIPALID"] = PrincipalID.ToString(); | ||
76 | sendData["FRIENDID"] = friendID.ToString(); | ||
77 | sendData["METHOD"] = "getfriendperms"; | ||
78 | sendData["KEY"] = m_ServiceKey; | ||
79 | sendData["SESSIONID"] = m_SessionID.ToString(); | ||
80 | |||
81 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
82 | |||
83 | try | ||
84 | { | ||
85 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
86 | m_ServerURI + "/hgfriends", | ||
87 | reqString); | ||
88 | if (reply != string.Empty) | ||
89 | { | ||
90 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
91 | |||
92 | if ((replyData != null) && replyData.ContainsKey("Value") && (replyData["Value"] != null)) | ||
93 | { | ||
94 | uint perms = 0; | ||
95 | uint.TryParse(replyData["Value"].ToString(), out perms); | ||
96 | return perms; | ||
97 | } | ||
98 | else | ||
99 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: GetFriendPerms {0} received null response", | ||
100 | PrincipalID); | ||
101 | |||
102 | } | ||
103 | } | ||
104 | catch (Exception e) | ||
105 | { | ||
106 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server: {0}", e.Message); | ||
107 | } | ||
108 | |||
109 | return 0; | ||
110 | |||
111 | } | ||
112 | |||
113 | public bool NewFriendship(UUID PrincipalID, string Friend) | ||
114 | { | ||
115 | FriendInfo finfo = new FriendInfo(); | ||
116 | finfo.PrincipalID = PrincipalID; | ||
117 | finfo.Friend = Friend; | ||
118 | |||
119 | Dictionary<string, object> sendData = finfo.ToKeyValuePairs(); | ||
120 | |||
121 | sendData["METHOD"] = "newfriendship"; | ||
122 | sendData["KEY"] = m_ServiceKey; | ||
123 | sendData["SESSIONID"] = m_SessionID.ToString(); | ||
124 | |||
125 | string reply = string.Empty; | ||
126 | try | ||
127 | { | ||
128 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
129 | m_ServerURI + "/hgfriends", | ||
130 | ServerUtils.BuildQueryString(sendData)); | ||
131 | } | ||
132 | catch (Exception e) | ||
133 | { | ||
134 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server: {0}", e.Message); | ||
135 | return false; | ||
136 | } | ||
137 | |||
138 | if (reply != string.Empty) | ||
139 | { | ||
140 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
141 | |||
142 | if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null)) | ||
143 | { | ||
144 | bool success = false; | ||
145 | Boolean.TryParse(replyData["Result"].ToString(), out success); | ||
146 | return success; | ||
147 | } | ||
148 | else | ||
149 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: StoreFriend {0} {1} received null response", | ||
150 | PrincipalID, Friend); | ||
151 | } | ||
152 | else | ||
153 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: StoreFriend received null reply"); | ||
154 | |||
155 | return false; | ||
156 | |||
157 | } | ||
158 | |||
159 | public bool DeleteFriendship(UUID PrincipalID, UUID Friend, string secret) | ||
160 | { | ||
161 | FriendInfo finfo = new FriendInfo(); | ||
162 | finfo.PrincipalID = PrincipalID; | ||
163 | finfo.Friend = Friend.ToString(); | ||
164 | |||
165 | Dictionary<string, object> sendData = finfo.ToKeyValuePairs(); | ||
166 | |||
167 | sendData["METHOD"] = "deletefriendship"; | ||
168 | sendData["SECRET"] = secret; | ||
169 | |||
170 | string reply = string.Empty; | ||
171 | try | ||
172 | { | ||
173 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
174 | m_ServerURI + "/hgfriends", | ||
175 | ServerUtils.BuildQueryString(sendData)); | ||
176 | } | ||
177 | catch (Exception e) | ||
178 | { | ||
179 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server: {0}", e.Message); | ||
180 | return false; | ||
181 | } | ||
182 | |||
183 | if (reply != string.Empty) | ||
184 | { | ||
185 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
186 | |||
187 | if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null)) | ||
188 | { | ||
189 | bool success = false; | ||
190 | Boolean.TryParse(replyData["Result"].ToString(), out success); | ||
191 | return success; | ||
192 | } | ||
193 | else | ||
194 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Delete {0} {1} received null response", | ||
195 | PrincipalID, Friend); | ||
196 | } | ||
197 | else | ||
198 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: DeleteFriend received null reply"); | ||
199 | |||
200 | return false; | ||
201 | |||
202 | } | ||
203 | |||
204 | #endregion | ||
205 | } | ||
206 | } \ No newline at end of file | ||
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index 7ddcfa6..4ce406c 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | |||
@@ -51,20 +51,31 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
51 | MethodBase.GetCurrentMethod().DeclaringType); | 51 | MethodBase.GetCurrentMethod().DeclaringType); |
52 | 52 | ||
53 | string m_ServerURL; | 53 | string m_ServerURL; |
54 | public UserAgentServiceConnector(string url) | 54 | |
55 | public UserAgentServiceConnector(string url) : this(url, true) | ||
56 | { | ||
57 | } | ||
58 | |||
59 | public UserAgentServiceConnector(string url, bool dnsLookup) | ||
55 | { | 60 | { |
56 | m_ServerURL = url; | 61 | m_ServerURL = url; |
57 | // Doing this here, because XML-RPC or mono have some strong ideas about | 62 | |
58 | // caching DNS translations. | 63 | if (dnsLookup) |
59 | try | ||
60 | { | ||
61 | Uri m_Uri = new Uri(m_ServerURL); | ||
62 | IPAddress ip = Util.GetHostFromDNS(m_Uri.Host); | ||
63 | m_ServerURL = m_ServerURL.Replace(m_Uri.Host, ip.ToString()); ; | ||
64 | } | ||
65 | catch (Exception e) | ||
66 | { | 64 | { |
67 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", m_ServerURL, e.Message); | 65 | // Doing this here, because XML-RPC or mono have some strong ideas about |
66 | // caching DNS translations. | ||
67 | try | ||
68 | { | ||
69 | Uri m_Uri = new Uri(m_ServerURL); | ||
70 | IPAddress ip = Util.GetHostFromDNS(m_Uri.Host); | ||
71 | m_ServerURL = m_ServerURL.Replace(m_Uri.Host, ip.ToString()); | ||
72 | if (!m_ServerURL.EndsWith("/")) | ||
73 | m_ServerURL += "/"; | ||
74 | } | ||
75 | catch (Exception e) | ||
76 | { | ||
77 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", m_ServerURL, e.Message); | ||
78 | } | ||
68 | } | 79 | } |
69 | m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL); | 80 | m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL); |
70 | } | 81 | } |
@@ -400,6 +411,329 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
400 | GetBoolResponse(request, out reason); | 411 | GetBoolResponse(request, out reason); |
401 | } | 412 | } |
402 | 413 | ||
414 | public List<UUID> StatusNotification(List<string> friends, UUID userID, bool online) | ||
415 | { | ||
416 | Hashtable hash = new Hashtable(); | ||
417 | hash["userID"] = userID.ToString(); | ||
418 | hash["online"] = online.ToString(); | ||
419 | int i = 0; | ||
420 | foreach (string s in friends) | ||
421 | { | ||
422 | hash["friend_" + i.ToString()] = s; | ||
423 | i++; | ||
424 | } | ||
425 | |||
426 | IList paramList = new ArrayList(); | ||
427 | paramList.Add(hash); | ||
428 | |||
429 | XmlRpcRequest request = new XmlRpcRequest("status_notification", paramList); | ||
430 | string reason = string.Empty; | ||
431 | |||
432 | // Send and get reply | ||
433 | List<UUID> friendsOnline = new List<UUID>(); | ||
434 | XmlRpcResponse response = null; | ||
435 | try | ||
436 | { | ||
437 | response = request.Send(m_ServerURL, 6000); | ||
438 | } | ||
439 | catch (Exception e) | ||
440 | { | ||
441 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL); | ||
442 | reason = "Exception: " + e.Message; | ||
443 | return friendsOnline; | ||
444 | } | ||
445 | |||
446 | if (response.IsFault) | ||
447 | { | ||
448 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString); | ||
449 | reason = "XMLRPC Fault"; | ||
450 | return friendsOnline; | ||
451 | } | ||
452 | |||
453 | hash = (Hashtable)response.Value; | ||
454 | //foreach (Object o in hash) | ||
455 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
456 | try | ||
457 | { | ||
458 | if (hash == null) | ||
459 | { | ||
460 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL); | ||
461 | reason = "Internal error 1"; | ||
462 | return friendsOnline; | ||
463 | } | ||
464 | |||
465 | // Here is the actual response | ||
466 | foreach (object key in hash.Keys) | ||
467 | { | ||
468 | if (key is string && ((string)key).StartsWith("friend_") && hash[key] != null) | ||
469 | { | ||
470 | UUID uuid; | ||
471 | if (UUID.TryParse(hash[key].ToString(), out uuid)) | ||
472 | friendsOnline.Add(uuid); | ||
473 | } | ||
474 | } | ||
475 | |||
476 | } | ||
477 | catch (Exception e) | ||
478 | { | ||
479 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response."); | ||
480 | reason = "Exception: " + e.Message; | ||
481 | } | ||
482 | |||
483 | return friendsOnline; | ||
484 | } | ||
485 | |||
486 | public List<UUID> GetOnlineFriends(UUID userID, List<string> friends) | ||
487 | { | ||
488 | Hashtable hash = new Hashtable(); | ||
489 | hash["userID"] = userID.ToString(); | ||
490 | int i = 0; | ||
491 | foreach (string s in friends) | ||
492 | { | ||
493 | hash["friend_" + i.ToString()] = s; | ||
494 | i++; | ||
495 | } | ||
496 | |||
497 | IList paramList = new ArrayList(); | ||
498 | paramList.Add(hash); | ||
499 | |||
500 | XmlRpcRequest request = new XmlRpcRequest("get_online_friends", paramList); | ||
501 | string reason = string.Empty; | ||
502 | |||
503 | // Send and get reply | ||
504 | List<UUID> online = new List<UUID>(); | ||
505 | XmlRpcResponse response = null; | ||
506 | try | ||
507 | { | ||
508 | response = request.Send(m_ServerURL, 10000); | ||
509 | } | ||
510 | catch (Exception e) | ||
511 | { | ||
512 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL); | ||
513 | reason = "Exception: " + e.Message; | ||
514 | return online; | ||
515 | } | ||
516 | |||
517 | if (response.IsFault) | ||
518 | { | ||
519 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString); | ||
520 | reason = "XMLRPC Fault"; | ||
521 | return online; | ||
522 | } | ||
523 | |||
524 | hash = (Hashtable)response.Value; | ||
525 | //foreach (Object o in hash) | ||
526 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
527 | try | ||
528 | { | ||
529 | if (hash == null) | ||
530 | { | ||
531 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL); | ||
532 | reason = "Internal error 1"; | ||
533 | return online; | ||
534 | } | ||
535 | |||
536 | // Here is the actual response | ||
537 | foreach (object key in hash.Keys) | ||
538 | { | ||
539 | if (key is string && ((string)key).StartsWith("friend_") && hash[key] != null) | ||
540 | { | ||
541 | UUID uuid; | ||
542 | if (UUID.TryParse(hash[key].ToString(), out uuid)) | ||
543 | online.Add(uuid); | ||
544 | } | ||
545 | } | ||
546 | |||
547 | } | ||
548 | catch (Exception e) | ||
549 | { | ||
550 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response."); | ||
551 | reason = "Exception: " + e.Message; | ||
552 | } | ||
553 | |||
554 | return online; | ||
555 | } | ||
556 | |||
557 | public Dictionary<string, object> GetServerURLs(UUID userID) | ||
558 | { | ||
559 | Hashtable hash = new Hashtable(); | ||
560 | hash["userID"] = userID.ToString(); | ||
561 | |||
562 | IList paramList = new ArrayList(); | ||
563 | paramList.Add(hash); | ||
564 | |||
565 | XmlRpcRequest request = new XmlRpcRequest("get_server_urls", paramList); | ||
566 | string reason = string.Empty; | ||
567 | |||
568 | // Send and get reply | ||
569 | Dictionary<string, object> serverURLs = new Dictionary<string,object>(); | ||
570 | XmlRpcResponse response = null; | ||
571 | try | ||
572 | { | ||
573 | response = request.Send(m_ServerURL, 10000); | ||
574 | } | ||
575 | catch (Exception e) | ||
576 | { | ||
577 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL); | ||
578 | reason = "Exception: " + e.Message; | ||
579 | return serverURLs; | ||
580 | } | ||
581 | |||
582 | if (response.IsFault) | ||
583 | { | ||
584 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString); | ||
585 | reason = "XMLRPC Fault"; | ||
586 | return serverURLs; | ||
587 | } | ||
588 | |||
589 | hash = (Hashtable)response.Value; | ||
590 | //foreach (Object o in hash) | ||
591 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
592 | try | ||
593 | { | ||
594 | if (hash == null) | ||
595 | { | ||
596 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetServerURLs Got null response from {0}! THIS IS BAAAAD", m_ServerURL); | ||
597 | reason = "Internal error 1"; | ||
598 | return serverURLs; | ||
599 | } | ||
600 | |||
601 | // Here is the actual response | ||
602 | foreach (object key in hash.Keys) | ||
603 | { | ||
604 | if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null) | ||
605 | { | ||
606 | string serverType = key.ToString().Substring(4); // remove "SRV_" | ||
607 | serverURLs.Add(serverType, hash[key].ToString()); | ||
608 | } | ||
609 | } | ||
610 | |||
611 | } | ||
612 | catch (Exception e) | ||
613 | { | ||
614 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response."); | ||
615 | reason = "Exception: " + e.Message; | ||
616 | } | ||
617 | |||
618 | return serverURLs; | ||
619 | } | ||
620 | |||
621 | public string LocateUser(UUID userID) | ||
622 | { | ||
623 | Hashtable hash = new Hashtable(); | ||
624 | hash["userID"] = userID.ToString(); | ||
625 | |||
626 | IList paramList = new ArrayList(); | ||
627 | paramList.Add(hash); | ||
628 | |||
629 | XmlRpcRequest request = new XmlRpcRequest("locate_user", paramList); | ||
630 | string reason = string.Empty; | ||
631 | |||
632 | // Send and get reply | ||
633 | string url = string.Empty; | ||
634 | XmlRpcResponse response = null; | ||
635 | try | ||
636 | { | ||
637 | response = request.Send(m_ServerURL, 10000); | ||
638 | } | ||
639 | catch (Exception e) | ||
640 | { | ||
641 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL); | ||
642 | reason = "Exception: " + e.Message; | ||
643 | return url; | ||
644 | } | ||
645 | |||
646 | if (response.IsFault) | ||
647 | { | ||
648 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString); | ||
649 | reason = "XMLRPC Fault"; | ||
650 | return url; | ||
651 | } | ||
652 | |||
653 | hash = (Hashtable)response.Value; | ||
654 | //foreach (Object o in hash) | ||
655 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
656 | try | ||
657 | { | ||
658 | if (hash == null) | ||
659 | { | ||
660 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: LocateUser Got null response from {0}! THIS IS BAAAAD", m_ServerURL); | ||
661 | reason = "Internal error 1"; | ||
662 | return url; | ||
663 | } | ||
664 | |||
665 | // Here's the actual response | ||
666 | if (hash.ContainsKey("URL")) | ||
667 | url = hash["URL"].ToString(); | ||
668 | |||
669 | } | ||
670 | catch (Exception e) | ||
671 | { | ||
672 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response."); | ||
673 | reason = "Exception: " + e.Message; | ||
674 | } | ||
675 | |||
676 | return url; | ||
677 | } | ||
678 | |||
679 | public string GetUUI(UUID userID, UUID targetUserID) | ||
680 | { | ||
681 | Hashtable hash = new Hashtable(); | ||
682 | hash["userID"] = userID.ToString(); | ||
683 | hash["targetUserID"] = targetUserID.ToString(); | ||
684 | |||
685 | IList paramList = new ArrayList(); | ||
686 | paramList.Add(hash); | ||
687 | |||
688 | XmlRpcRequest request = new XmlRpcRequest("get_uui", paramList); | ||
689 | string reason = string.Empty; | ||
690 | |||
691 | // Send and get reply | ||
692 | string uui = string.Empty; | ||
693 | XmlRpcResponse response = null; | ||
694 | try | ||
695 | { | ||
696 | response = request.Send(m_ServerURL, 10000); | ||
697 | } | ||
698 | catch (Exception e) | ||
699 | { | ||
700 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL); | ||
701 | reason = "Exception: " + e.Message; | ||
702 | return uui; | ||
703 | } | ||
704 | |||
705 | if (response.IsFault) | ||
706 | { | ||
707 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString); | ||
708 | reason = "XMLRPC Fault"; | ||
709 | return uui; | ||
710 | } | ||
711 | |||
712 | hash = (Hashtable)response.Value; | ||
713 | //foreach (Object o in hash) | ||
714 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
715 | try | ||
716 | { | ||
717 | if (hash == null) | ||
718 | { | ||
719 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUI Got null response from {0}! THIS IS BAAAAD", m_ServerURL); | ||
720 | reason = "Internal error 1"; | ||
721 | return uui; | ||
722 | } | ||
723 | |||
724 | // Here's the actual response | ||
725 | if (hash.ContainsKey("UUI")) | ||
726 | uui = hash["UUI"].ToString(); | ||
727 | |||
728 | } | ||
729 | catch (Exception e) | ||
730 | { | ||
731 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response."); | ||
732 | reason = "Exception: " + e.Message; | ||
733 | } | ||
734 | |||
735 | return uui; | ||
736 | } | ||
403 | 737 | ||
404 | private bool GetBoolResponse(XmlRpcRequest request, out string reason) | 738 | private bool GetBoolResponse(XmlRpcRequest request, out string reason) |
405 | { | 739 | { |
diff --git a/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs new file mode 100644 index 0000000..dbce9f6 --- /dev/null +++ b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs | |||
@@ -0,0 +1,131 @@ | |||
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 | using System; | ||
28 | using System.Collections; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenMetaverse; | ||
34 | using Nwc.XmlRpc; | ||
35 | using log4net; | ||
36 | |||
37 | using OpenSim.Framework; | ||
38 | |||
39 | namespace 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, 10000); | ||
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 | m_log.DebugFormat("[GRID INSTANT MESSAGE]: No response from {0}", url); | ||
84 | return false; | ||
85 | } | ||
86 | } | ||
87 | catch (WebException e) | ||
88 | { | ||
89 | m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to {0} the host didn't respond " + e.ToString(), url); | ||
90 | } | ||
91 | |||
92 | return false; | ||
93 | } | ||
94 | |||
95 | /// <summary> | ||
96 | /// Takes a GridInstantMessage and converts it into a Hashtable for XMLRPC | ||
97 | /// </summary> | ||
98 | /// <param name="msg">The GridInstantMessage object</param> | ||
99 | /// <returns>Hashtable containing the XMLRPC request</returns> | ||
100 | protected static Hashtable ConvertGridInstantMessageToXMLRPC(GridInstantMessage msg) | ||
101 | { | ||
102 | Hashtable gim = new Hashtable(); | ||
103 | gim["from_agent_id"] = msg.fromAgentID.ToString(); | ||
104 | // Kept for compatibility | ||
105 | gim["from_agent_session"] = UUID.Zero.ToString(); | ||
106 | gim["to_agent_id"] = msg.toAgentID.ToString(); | ||
107 | gim["im_session_id"] = msg.imSessionID.ToString(); | ||
108 | gim["timestamp"] = msg.timestamp.ToString(); | ||
109 | gim["from_agent_name"] = msg.fromAgentName; | ||
110 | gim["message"] = msg.message; | ||
111 | byte[] dialogdata = new byte[1]; dialogdata[0] = msg.dialog; | ||
112 | gim["dialog"] = Convert.ToBase64String(dialogdata, Base64FormattingOptions.None); | ||
113 | |||
114 | if (msg.fromGroup) | ||
115 | gim["from_group"] = "TRUE"; | ||
116 | else | ||
117 | gim["from_group"] = "FALSE"; | ||
118 | byte[] offlinedata = new byte[1]; offlinedata[0] = msg.offline; | ||
119 | gim["offline"] = Convert.ToBase64String(offlinedata, Base64FormattingOptions.None); | ||
120 | gim["parent_estate_id"] = msg.ParentEstateID.ToString(); | ||
121 | gim["position_x"] = msg.Position.X.ToString(); | ||
122 | gim["position_y"] = msg.Position.Y.ToString(); | ||
123 | gim["position_z"] = msg.Position.Z.ToString(); | ||
124 | gim["region_id"] = msg.RegionID.ToString(); | ||
125 | gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket, Base64FormattingOptions.None); | ||
126 | |||
127 | return gim; | ||
128 | } | ||
129 | |||
130 | } | ||
131 | } | ||
diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServiceConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServiceConnector.cs new file mode 100644 index 0000000..520d639 --- /dev/null +++ b/OpenSim/Services/Connectors/MapImage/MapImageServiceConnector.cs | |||
@@ -0,0 +1,157 @@ | |||
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 log4net; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Net; | ||
33 | using System.Reflection; | ||
34 | |||
35 | using Nini.Config; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Console; | ||
38 | using OpenSim.Framework.Communications; | ||
39 | using OpenSim.Server.Base; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using OpenMetaverse; | ||
42 | using OpenMetaverse.StructuredData; | ||
43 | |||
44 | namespace OpenSim.Services.Connectors | ||
45 | { | ||
46 | public class MapImageServicesConnector : IMapImageService | ||
47 | { | ||
48 | private static readonly ILog m_log = | ||
49 | LogManager.GetLogger( | ||
50 | MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | private string m_ServerURI = String.Empty; | ||
53 | private IImprovedAssetCache m_Cache = null; | ||
54 | |||
55 | public MapImageServicesConnector() | ||
56 | { | ||
57 | } | ||
58 | |||
59 | public MapImageServicesConnector(string serverURI) | ||
60 | { | ||
61 | m_ServerURI = serverURI.TrimEnd('/'); | ||
62 | } | ||
63 | |||
64 | public MapImageServicesConnector(IConfigSource source) | ||
65 | { | ||
66 | Initialise(source); | ||
67 | } | ||
68 | |||
69 | public virtual void Initialise(IConfigSource source) | ||
70 | { | ||
71 | IConfig config = source.Configs["MapImageService"]; | ||
72 | if (config == null) | ||
73 | { | ||
74 | m_log.Error("[MAP IMAGE CONNECTOR]: MapImageService missing"); | ||
75 | throw new Exception("MapImage connector init error"); | ||
76 | } | ||
77 | |||
78 | string serviceURI = config.GetString("MapImageServerURI", | ||
79 | String.Empty); | ||
80 | |||
81 | if (serviceURI == String.Empty) | ||
82 | { | ||
83 | m_log.Error("[MAP IMAGE CONNECTOR]: No Server URI named in section MapImageService"); | ||
84 | throw new Exception("MapImage connector init error"); | ||
85 | } | ||
86 | m_ServerURI = serviceURI; | ||
87 | m_ServerURI = serviceURI.TrimEnd('/'); | ||
88 | } | ||
89 | |||
90 | public bool AddMapTile(int x, int y, byte[] jpgData, out string reason) | ||
91 | { | ||
92 | reason = string.Empty; | ||
93 | int tickstart = Util.EnvironmentTickCount(); | ||
94 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
95 | sendData["X"] = x.ToString(); | ||
96 | sendData["Y"] = y.ToString(); | ||
97 | sendData["TYPE"] = "image/jpeg"; | ||
98 | sendData["DATA"] = Convert.ToBase64String(jpgData); | ||
99 | |||
100 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
101 | |||
102 | try | ||
103 | { | ||
104 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
105 | m_ServerURI + "/map", | ||
106 | reqString); | ||
107 | if (reply != string.Empty) | ||
108 | { | ||
109 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
110 | |||
111 | if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "success")) | ||
112 | { | ||
113 | return true; | ||
114 | } | ||
115 | else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure")) | ||
116 | { | ||
117 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Registration failed: {0}", replyData["Message"].ToString()); | ||
118 | reason = replyData["Message"].ToString(); | ||
119 | return false; | ||
120 | } | ||
121 | else if (!replyData.ContainsKey("Result")) | ||
122 | { | ||
123 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: reply data does not contain result field"); | ||
124 | } | ||
125 | else | ||
126 | { | ||
127 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: unexpected result {0}", replyData["Result"].ToString()); | ||
128 | reason = "Unexpected result " + replyData["Result"].ToString(); | ||
129 | } | ||
130 | |||
131 | } | ||
132 | else | ||
133 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: RegisterRegion received null reply"); | ||
134 | } | ||
135 | catch (Exception e) | ||
136 | { | ||
137 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
138 | } | ||
139 | finally | ||
140 | { | ||
141 | // This just dumps a warning for any operation that takes more than 100 ms | ||
142 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | ||
143 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: map tile uploaded in {0}ms", tickdiff); | ||
144 | } | ||
145 | |||
146 | return false; | ||
147 | |||
148 | } | ||
149 | |||
150 | public byte[] GetMapTile(string fileName, out string format) | ||
151 | { | ||
152 | format = string.Empty; | ||
153 | new Exception("GetMapTile method not Implemented"); | ||
154 | return null; | ||
155 | } | ||
156 | } | ||
157 | } | ||
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs index 6f2d735..7422d94 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs | |||
@@ -78,6 +78,11 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
78 | 78 | ||
79 | public FriendInfo[] GetFriends(UUID principalID) | 79 | public FriendInfo[] GetFriends(UUID principalID) |
80 | { | 80 | { |
81 | return GetFriends(principalID.ToString()); | ||
82 | } | ||
83 | |||
84 | public FriendInfo[] GetFriends(string principalID) | ||
85 | { | ||
81 | if (String.IsNullOrEmpty(m_serverUrl)) | 86 | if (String.IsNullOrEmpty(m_serverUrl)) |
82 | return new FriendInfo[0]; | 87 | return new FriendInfo[0]; |
83 | 88 | ||
@@ -95,7 +100,14 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
95 | UUID friendID = friendEntry["Key"].AsUUID(); | 100 | UUID friendID = friendEntry["Key"].AsUUID(); |
96 | 101 | ||
97 | FriendInfo friend = new FriendInfo(); | 102 | FriendInfo friend = new FriendInfo(); |
98 | friend.PrincipalID = principalID; | 103 | if (!UUID.TryParse(principalID, out friend.PrincipalID)) |
104 | { | ||
105 | string tmp = string.Empty; | ||
106 | if (!Util.ParseUniversalUserIdentifier(principalID, out friend.PrincipalID, out tmp, out tmp, out tmp, out tmp)) | ||
107 | // bad record. ignore this entry | ||
108 | continue; | ||
109 | } | ||
110 | |||
99 | friend.Friend = friendID.ToString(); | 111 | friend.Friend = friendID.ToString(); |
100 | friend.MyFlags = friendEntry["Value"].AsInteger(); | 112 | friend.MyFlags = friendEntry["Value"].AsInteger(); |
101 | friend.TheirFlags = -1; | 113 | friend.TheirFlags = -1; |
@@ -127,7 +139,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
127 | return array; | 139 | return array; |
128 | } | 140 | } |
129 | 141 | ||
130 | public bool StoreFriend(UUID principalID, string friend, int flags) | 142 | public bool StoreFriend(string principalID, string friend, int flags) |
131 | { | 143 | { |
132 | if (String.IsNullOrEmpty(m_serverUrl)) | 144 | if (String.IsNullOrEmpty(m_serverUrl)) |
133 | return true; | 145 | return true; |
@@ -152,6 +164,11 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
152 | 164 | ||
153 | public bool Delete(UUID principalID, string friend) | 165 | public bool Delete(UUID principalID, string friend) |
154 | { | 166 | { |
167 | return Delete(principalID.ToString(), friend); | ||
168 | } | ||
169 | |||
170 | public bool Delete(string principalID, string friend) | ||
171 | { | ||
155 | if (String.IsNullOrEmpty(m_serverUrl)) | 172 | if (String.IsNullOrEmpty(m_serverUrl)) |
156 | return true; | 173 | return true; |
157 | 174 | ||
@@ -174,7 +191,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
174 | 191 | ||
175 | #endregion IFriendsService | 192 | #endregion IFriendsService |
176 | 193 | ||
177 | private OSDArray GetFriended(UUID ownerID) | 194 | private OSDArray GetFriended(string ownerID) |
178 | { | 195 | { |
179 | NameValueCollection requestArgs = new NameValueCollection | 196 | NameValueCollection requestArgs = new NameValueCollection |
180 | { | 197 | { |
@@ -195,7 +212,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
195 | } | 212 | } |
196 | } | 213 | } |
197 | 214 | ||
198 | private OSDArray GetFriendedBy(UUID ownerID) | 215 | private OSDArray GetFriendedBy(string ownerID) |
199 | { | 216 | { |
200 | NameValueCollection requestArgs = new NameValueCollection | 217 | NameValueCollection requestArgs = new NameValueCollection |
201 | { | 218 | { |
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 725c6df..6fb583c 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs | |||
@@ -103,16 +103,31 @@ namespace OpenSim.Services.Connectors.Simulation | |||
103 | args["teleport_flags"] = OSD.FromString(flags.ToString()); | 103 | args["teleport_flags"] = OSD.FromString(flags.ToString()); |
104 | 104 | ||
105 | OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000); | 105 | OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000); |
106 | if (result["Success"].AsBoolean()) | 106 | bool success = result["success"].AsBoolean(); |
107 | return true; | 107 | if (success && result.ContainsKey("_Result")) |
108 | 108 | { | |
109 | OSDMap data = (OSDMap)result["_Result"]; | ||
110 | |||
111 | reason = data["reason"].AsString(); | ||
112 | success = data["success"].AsBoolean(); | ||
113 | return success; | ||
114 | } | ||
115 | |||
116 | // Try the old version, uncompressed | ||
109 | result = WebUtil.PostToService(uri, args, 30000); | 117 | result = WebUtil.PostToService(uri, args, 30000); |
110 | 118 | ||
111 | if (result["Success"].AsBoolean()) | 119 | if (result["Success"].AsBoolean()) |
112 | { | 120 | { |
113 | m_log.WarnFormat( | 121 | if (result.ContainsKey("_Result")) |
114 | "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName); | 122 | { |
115 | return true; | 123 | OSDMap data = (OSDMap)result["_Result"]; |
124 | |||
125 | reason = data["reason"].AsString(); | ||
126 | success = data["success"].AsBoolean(); | ||
127 | m_log.WarnFormat( | ||
128 | "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName); | ||
129 | return success; | ||
130 | } | ||
116 | } | 131 | } |
117 | 132 | ||
118 | m_log.WarnFormat( | 133 | m_log.WarnFormat( |