29 using System.Collections.Generic;
30 using System.Reflection;
32 using OpenSim.Services.Interfaces;
34 using OpenSim.Server.Base;
35 using OpenSim.Framework;
40 namespace OpenSim.Services.Connectors.Friends
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 return FriendshipOffered(region, userID, friendID, message, String.Empty);
58 Dictionary<string, object> sendData =
new Dictionary<string, object>();
61 sendData[
"METHOD"] =
"friendship_offered";
63 sendData[
"FromID"] = userID.ToString();
64 sendData[
"ToID"] = friendID.ToString();
65 sendData[
"Message"] = message;
66 if (userName != String.Empty)
67 sendData[
"FromName"] = userName;
69 return Call(region, sendData);
74 Dictionary<string, object> sendData =
new Dictionary<string, object>();
77 sendData[
"METHOD"] =
"friendship_approved";
79 sendData[
"FromID"] = userID.ToString();
80 sendData[
"FromName"] = userName;
81 sendData[
"ToID"] = friendID.ToString();
83 return Call(region, sendData);
91 Dictionary<string, object> sendData =
new Dictionary<string, object>();
94 sendData[
"METHOD"] =
"friendship_denied";
96 sendData[
"FromID"] = userID.ToString();
97 sendData[
"FromName"] = userName;
98 sendData[
"ToID"] = friendID.ToString();
100 return Call(region, sendData);
105 Dictionary<string, object> sendData =
new Dictionary<string, object>();
108 sendData[
"METHOD"] =
"friendship_terminated";
110 sendData[
"FromID"] = userID.ToString();
111 sendData[
"ToID"] = friendID.ToString();
113 return Call(region, sendData);
118 Dictionary<string, object> sendData =
new Dictionary<string, object>();
121 sendData[
"METHOD"] =
"grant_rights";
123 sendData[
"FromID"] = userID.ToString();
124 sendData[
"ToID"] = friendID.ToString();
125 sendData[
"UserFlags"] = userFlags.ToString();
126 sendData[
"Rights"] = rights.ToString();
128 return Call(region, sendData);
133 Dictionary<string, object> sendData =
new Dictionary<string, object>();
136 sendData[
"METHOD"] =
"status";
138 sendData[
"FromID"] = userID.ToString();
139 sendData[
"ToID"] = friendID;
140 sendData[
"Online"] = online.ToString();
142 return Call(region, sendData);
145 private bool Call(
GridRegion region, Dictionary<string, object> sendData)
147 Util.FireAndForget(x => {
148 string reqString = ServerUtils.BuildQueryString(sendData);
153 string path = ServicePath();
156 string uri = region.ServerURI + path;
161 string reply = SynchronousRestFormsRequester.MakeRequest(
"POST", uri, reqString);
162 if (reply !=
string.Empty)
164 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
166 if (replyData.ContainsKey(
"RESULT"))
174 m_log.DebugFormat(
"[FRIENDS SIM CONNECTOR]: reply data does not contain result field");
178 m_log.DebugFormat(
"[FRIENDS SIM CONNECTOR]: received empty reply");
182 m_log.DebugFormat(
"[FRIENDS SIM CONNECTOR]: Exception when contacting remote sim at {0}: {1}", uri, e.Message);
bool GrantRights(GridRegion region, UUID userID, UUID friendID, int userFlags, int rights)
bool FriendshipOffered(GridRegion region, UUID userID, UUID friendID, string message)
bool FriendshipTerminated(GridRegion region, UUID userID, UUID friendID)
virtual string ServicePath()
bool FriendshipApproved(GridRegion region, UUID userID, string userName, UUID friendID)
bool StatusNotify(GridRegion region, UUID userID, string friendID, bool online)
virtual bool FriendshipOffered(GridRegion region, UUID userID, UUID friendID, string message, string userName)
string ServerURI
A well-formed URI for the host region server (namely "http://" + ExternalHostName) ...
bool FriendshipDenied(GridRegion region, UUID userID, string userName, UUID friendID)
OpenSim.Services.Interfaces.GridRegion GridRegion