diff options
author | Diva Canto | 2010-02-28 08:36:13 -0800 |
---|---|---|
committer | Diva Canto | 2010-02-28 08:36:13 -0800 |
commit | db24e57cab88217e49c3c564a2c025a44199520e (patch) | |
tree | aba907fab21486840d5dcc970c7c77189dd96549 /OpenSim/Services/Connectors | |
parent | Status notification (online/offline) working for same sim. (diff) | |
download | opensim-SC_OLD-db24e57cab88217e49c3c564a2c025a44199520e.zip opensim-SC_OLD-db24e57cab88217e49c3c564a2c025a44199520e.tar.gz opensim-SC_OLD-db24e57cab88217e49c3c564a2c025a44199520e.tar.bz2 opensim-SC_OLD-db24e57cab88217e49c3c564a2c025a44199520e.tar.xz |
Friends connectors finished. Status notification working across the board. One last bug: friends online upon login are not being sent to the user.
Diffstat (limited to 'OpenSim/Services/Connectors')
-rw-r--r-- | OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs | 112 |
1 files changed, 103 insertions, 9 deletions
diff --git a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs index 081e354..490c8cf 100644 --- a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs +++ b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs | |||
@@ -27,45 +27,139 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | ||
30 | 31 | ||
31 | using OpenSim.Services.Interfaces; | 32 | using OpenSim.Services.Interfaces; |
32 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 33 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
34 | using OpenSim.Server.Base; | ||
35 | using OpenSim.Framework.Servers.HttpServer; | ||
33 | 36 | ||
34 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using log4net; | ||
35 | 39 | ||
36 | namespace OpenSim.Services.Connectors.Friends | 40 | namespace OpenSim.Services.Connectors.Friends |
37 | { | 41 | { |
38 | public class FriendsSimConnector | 42 | public class FriendsSimConnector |
39 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
40 | 45 | ||
41 | public bool FriendshipOffered(GridRegion region, UUID userID, UUID friendID, string message) | 46 | public bool FriendshipOffered(GridRegion region, UUID userID, UUID friendID, string message) |
42 | { | 47 | { |
43 | return true; | 48 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
49 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
50 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
51 | sendData["METHOD"] = "friendship_offered"; | ||
52 | |||
53 | sendData["FromID"] = userID.ToString(); | ||
54 | sendData["ToID"] = friendID.ToString(); | ||
55 | sendData["Message"] = message; | ||
56 | |||
57 | return Call(region, sendData); | ||
58 | |||
44 | } | 59 | } |
45 | 60 | ||
46 | public bool FriendshipApproved(GridRegion region, UUID userID, UUID friendID) | 61 | public bool FriendshipApproved(GridRegion region, UUID userID, string userName, UUID friendID) |
47 | { | 62 | { |
48 | return true; | 63 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
64 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
65 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
66 | sendData["METHOD"] = "friendship_approved"; | ||
67 | |||
68 | sendData["FromID"] = userID.ToString(); | ||
69 | sendData["FromName"] = userName; | ||
70 | sendData["ToID"] = friendID.ToString(); | ||
71 | |||
72 | return Call(region, sendData); | ||
49 | } | 73 | } |
50 | 74 | ||
51 | public bool FriendshipDenied(GridRegion region, UUID userID, UUID friendID) | 75 | public bool FriendshipDenied(GridRegion region, UUID userID, string userName, UUID friendID) |
52 | { | 76 | { |
53 | return true; | 77 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
78 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
79 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
80 | sendData["METHOD"] = "friendship_denied"; | ||
81 | |||
82 | sendData["FromID"] = userID.ToString(); | ||
83 | sendData["FromName"] = userName; | ||
84 | sendData["ToID"] = friendID.ToString(); | ||
85 | |||
86 | return Call(region, sendData); | ||
54 | } | 87 | } |
55 | 88 | ||
56 | public bool FriendshipTerminated(GridRegion region, UUID userID, UUID friendID) | 89 | public bool FriendshipTerminated(GridRegion region, UUID userID, UUID friendID) |
57 | { | 90 | { |
58 | return true; | 91 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
92 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
93 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
94 | sendData["METHOD"] = "friendship_terminated"; | ||
95 | |||
96 | sendData["FromID"] = userID.ToString(); | ||
97 | sendData["ToID"] = friendID.ToString(); | ||
98 | |||
99 | return Call(region, sendData); | ||
59 | } | 100 | } |
60 | 101 | ||
61 | public bool GrantRights(GridRegion region, UUID requester, UUID target) | 102 | public bool GrantRights(GridRegion region, UUID userID, UUID friendID) |
62 | { | 103 | { |
63 | return true; | 104 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
105 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
106 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
107 | sendData["METHOD"] = "grant_rights"; | ||
108 | |||
109 | sendData["FromID"] = userID.ToString(); | ||
110 | sendData["ToID"] = friendID.ToString(); | ||
111 | |||
112 | return Call(region, sendData); | ||
64 | } | 113 | } |
65 | 114 | ||
66 | public bool StatusNotify(GridRegion region, UUID userID, UUID friendID, bool online) | 115 | public bool StatusNotify(GridRegion region, UUID userID, UUID friendID, bool online) |
67 | { | 116 | { |
68 | return true; | 117 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
118 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
119 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
120 | sendData["METHOD"] = "status"; | ||
121 | |||
122 | sendData["FromID"] = userID.ToString(); | ||
123 | sendData["ToID"] = friendID.ToString(); | ||
124 | sendData["Online"] = online.ToString(); | ||
125 | |||
126 | return Call(region, sendData); | ||
127 | } | ||
128 | |||
129 | private bool Call(GridRegion region, Dictionary<string, object> sendData) | ||
130 | { | ||
131 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
132 | // m_log.DebugFormat("[FRIENDS CONNECTOR]: queryString = {0}", reqString); | ||
133 | try | ||
134 | { | ||
135 | string url = "http://" + region.ExternalHostName + ":" + region.HttpPort; | ||
136 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
137 | url + "/friends", | ||
138 | reqString); | ||
139 | if (reply != string.Empty) | ||
140 | { | ||
141 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
142 | |||
143 | if (replyData.ContainsKey("RESULT")) | ||
144 | { | ||
145 | if (replyData["RESULT"].ToString().ToLower() == "true") | ||
146 | return true; | ||
147 | else | ||
148 | return false; | ||
149 | } | ||
150 | else | ||
151 | m_log.DebugFormat("[FRIENDS CONNECTOR]: reply data does not contain result field"); | ||
152 | |||
153 | } | ||
154 | else | ||
155 | m_log.DebugFormat("[FRIENDS CONNECTOR]: received empty reply"); | ||
156 | } | ||
157 | catch (Exception e) | ||
158 | { | ||
159 | m_log.DebugFormat("[FRIENDS CONNECTOR]: Exception when contacting remote sim: {0}", e.Message); | ||
160 | } | ||
161 | |||
162 | return false; | ||
69 | } | 163 | } |
70 | } | 164 | } |
71 | } | 165 | } |