diff options
Diffstat (limited to 'OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs')
-rw-r--r-- | OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs index ba4c3c5..a0ac5f9 100644 --- a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs +++ b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs | |||
@@ -36,6 +36,7 @@ using Nini.Config; | |||
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Console; | 37 | using OpenSim.Framework.Console; |
38 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
39 | using OpenSim.Framework.ServiceAuth; | ||
39 | using OpenSim.Server.Base; | 40 | using OpenSim.Server.Base; |
40 | using OpenSim.Services.Interfaces; | 41 | using OpenSim.Services.Interfaces; |
41 | using OpenMetaverse; | 42 | using OpenMetaverse; |
@@ -43,7 +44,7 @@ using OpenMetaverse.StructuredData; | |||
43 | 44 | ||
44 | namespace OpenSim.Services.Connectors | 45 | namespace OpenSim.Services.Connectors |
45 | { | 46 | { |
46 | public class MapImageServicesConnector : IMapImageService | 47 | public class MapImageServicesConnector : BaseServiceConnector, IMapImageService |
47 | { | 48 | { |
48 | private static readonly ILog m_log = | 49 | private static readonly ILog m_log = |
49 | LogManager.GetLogger( | 50 | LogManager.GetLogger( |
@@ -84,6 +85,68 @@ namespace OpenSim.Services.Connectors | |||
84 | } | 85 | } |
85 | m_ServerURI = serviceURI; | 86 | m_ServerURI = serviceURI; |
86 | m_ServerURI = serviceURI.TrimEnd('/'); | 87 | m_ServerURI = serviceURI.TrimEnd('/'); |
88 | base.Initialise(source, "MapImageService"); | ||
89 | } | ||
90 | |||
91 | public bool RemoveMapTile(int x, int y, out string reason) | ||
92 | { | ||
93 | reason = string.Empty; | ||
94 | int tickstart = Util.EnvironmentTickCount(); | ||
95 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
96 | sendData["X"] = x.ToString(); | ||
97 | sendData["Y"] = y.ToString(); | ||
98 | |||
99 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
100 | string uri = m_ServerURI + "/removemap"; | ||
101 | |||
102 | try | ||
103 | { | ||
104 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
105 | uri, | ||
106 | reqString, | ||
107 | m_Auth); | ||
108 | if (reply != string.Empty) | ||
109 | { | ||
110 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
111 | |||
112 | if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "success")) | ||
113 | { | ||
114 | return true; | ||
115 | } | ||
116 | else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure")) | ||
117 | { | ||
118 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Delete failed: {0}", replyData["Message"].ToString()); | ||
119 | reason = replyData["Message"].ToString(); | ||
120 | return false; | ||
121 | } | ||
122 | else if (!replyData.ContainsKey("Result")) | ||
123 | { | ||
124 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: reply data does not contain result field"); | ||
125 | } | ||
126 | else | ||
127 | { | ||
128 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: unexpected result {0}", replyData["Result"].ToString()); | ||
129 | reason = "Unexpected result " + replyData["Result"].ToString(); | ||
130 | } | ||
131 | |||
132 | } | ||
133 | else | ||
134 | { | ||
135 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Map post received null reply"); | ||
136 | } | ||
137 | } | ||
138 | catch (Exception e) | ||
139 | { | ||
140 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Exception when contacting map server at {0}: {1}", uri, e.Message); | ||
141 | } | ||
142 | finally | ||
143 | { | ||
144 | // This just dumps a warning for any operation that takes more than 100 ms | ||
145 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | ||
146 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: map tile deleted in {0}ms", tickdiff); | ||
147 | } | ||
148 | |||
149 | return false; | ||
87 | } | 150 | } |
88 | 151 | ||
89 | public bool RemoveMapTile(int x, int y, UUID scopeID, out string reason) | 152 | public bool RemoveMapTile(int x, int y, UUID scopeID, out string reason) |
@@ -165,7 +228,8 @@ namespace OpenSim.Services.Connectors | |||
165 | { | 228 | { |
166 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | 229 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", |
167 | uri, | 230 | uri, |
168 | reqString); | 231 | reqString, |
232 | m_Auth); | ||
169 | if (reply != string.Empty) | 233 | if (reply != string.Empty) |
170 | { | 234 | { |
171 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | 235 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |