aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors
diff options
context:
space:
mode:
authorMelanie2013-06-23 01:59:57 +0100
committerMelanie2013-06-23 01:59:57 +0100
commitf70357eaa355b8c152f3d793d0fceafa14df5fd4 (patch)
treeffda32c340bd7f6d69652e9d9a959c7396f42a2f /OpenSim/Services/Connectors
parentMerge branch 'avination-current' into careminster (diff)
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC_OLD-f70357eaa355b8c152f3d793d0fceafa14df5fd4.zip
opensim-SC_OLD-f70357eaa355b8c152f3d793d0fceafa14df5fd4.tar.gz
opensim-SC_OLD-f70357eaa355b8c152f3d793d0fceafa14df5fd4.tar.bz2
opensim-SC_OLD-f70357eaa355b8c152f3d793d0fceafa14df5fd4.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Framework/Monitoring/BaseStatsCollector.cs OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
Diffstat (limited to 'OpenSim/Services/Connectors')
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs68
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs138
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs31
3 files changed, 63 insertions, 174 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index d840527..803cd1b 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -53,7 +53,8 @@ namespace OpenSim.Services.Connectors.Hypergrid
53 53
54 private IAssetService m_AssetService; 54 private IAssetService m_AssetService;
55 55
56 public GatekeeperServiceConnector() : base() 56 public GatekeeperServiceConnector()
57 : base()
57 { 58 {
58 } 59 }
59 60
@@ -123,11 +124,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
123 realHandle = Convert.ToUInt64((string)hash["handle"]); 124 realHandle = Convert.ToUInt64((string)hash["handle"]);
124 //m_log.Debug(">> HERE, realHandle: " + realHandle); 125 //m_log.Debug(">> HERE, realHandle: " + realHandle);
125 } 126 }
126 if (hash["region_image"] != null) { 127 if (hash["region_image"] != null)
128 {
127 imageURL = (string)hash["region_image"]; 129 imageURL = (string)hash["region_image"];
128 //m_log.Debug(">> HERE, imageURL: " + imageURL); 130 //m_log.Debug(">> HERE, imageURL: " + imageURL);
129 } 131 }
130 if (hash["external_name"] != null) { 132 if (hash["external_name"] != null)
133 {
131 externalName = (string)hash["external_name"]; 134 externalName = (string)hash["external_name"];
132 //m_log.Debug(">> HERE, externalName: " + externalName); 135 //m_log.Debug(">> HERE, externalName: " + externalName);
133 } 136 }
@@ -179,7 +182,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
179 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); 182 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
180 imageData = OpenJPEG.EncodeFromImage(bitmap, true); 183 imageData = OpenJPEG.EncodeFromImage(bitmap, true);
181 } 184 }
182 185
183 AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString()); 186 AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString());
184 187
185 // !!! for now 188 // !!! for now
@@ -257,7 +260,8 @@ namespace OpenSim.Services.Connectors.Hypergrid
257 region.RegionName = (string)hash["region_name"]; 260 region.RegionName = (string)hash["region_name"];
258 //m_log.Debug(">> HERE, region_name: " + region.RegionName); 261 //m_log.Debug(">> HERE, region_name: " + region.RegionName);
259 } 262 }
260 if (hash["hostname"] != null) { 263 if (hash["hostname"] != null)
264 {
261 region.ExternalHostName = (string)hash["hostname"]; 265 region.ExternalHostName = (string)hash["hostname"];
262 //m_log.Debug(">> HERE, hostname: " + region.ExternalHostName); 266 //m_log.Debug(">> HERE, hostname: " + region.ExternalHostName);
263 } 267 }
@@ -275,10 +279,10 @@ namespace OpenSim.Services.Connectors.Hypergrid
275 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); 279 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
276 //m_log.Debug(">> HERE, internal_port: " + region.InternalEndPoint); 280 //m_log.Debug(">> HERE, internal_port: " + region.InternalEndPoint);
277 } 281 }
278 282
279 if (hash["server_uri"] != null) 283 if (hash["server_uri"] != null)
280 { 284 {
281 region.ServerURI = (string) hash["server_uri"]; 285 region.ServerURI = (string)hash["server_uri"];
282 //m_log.Debug(">> HERE, server_uri: " + region.ServerURI); 286 //m_log.Debug(">> HERE, server_uri: " + region.ServerURI);
283 } 287 }
284 288
@@ -295,55 +299,5 @@ namespace OpenSim.Services.Connectors.Hypergrid
295 299
296 return null; 300 return null;
297 } 301 }
298
299 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason)
300 {
301 // m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: CreateAgent start");
302
303 myipaddress = String.Empty;
304 reason = String.Empty;
305
306 if (destination == null)
307 {
308 m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Given destination is null");
309 return false;
310 }
311
312 string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/";
313
314 try
315 {
316 OSDMap args = aCircuit.PackAgentCircuitData();
317
318 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
319 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
320 args["destination_name"] = OSD.FromString(destination.RegionName);
321 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
322 args["teleport_flags"] = OSD.FromString(flags.ToString());
323
324 OSDMap result = WebUtil.PostToService(uri, args, 80000);
325 if (result["Success"].AsBoolean())
326 {
327 OSDMap unpacked = (OSDMap)result["_Result"];
328
329 if (unpacked != null)
330 {
331 reason = unpacked["reason"].AsString();
332 myipaddress = unpacked["your_ip"].AsString();
333 return unpacked["success"].AsBoolean();
334 }
335 }
336
337 reason = result["Message"] != null ? result["Message"].AsString() : "error";
338 return false;
339 }
340 catch (Exception e)
341 {
342 m_log.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e.ToString());
343 reason = e.Message;
344 }
345
346 return false;
347 }
348 } 302 }
349} 303}
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index d7e38f1..5f5b7a7 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -44,13 +44,14 @@ using Nini.Config;
44 44
45namespace OpenSim.Services.Connectors.Hypergrid 45namespace OpenSim.Services.Connectors.Hypergrid
46{ 46{
47 public class UserAgentServiceConnector : IUserAgentService 47 public class UserAgentServiceConnector : SimulationServiceConnector, IUserAgentService
48 { 48 {
49 private static readonly ILog m_log = 49 private static readonly ILog m_log =
50 LogManager.GetLogger( 50 LogManager.GetLogger(
51 MethodBase.GetCurrentMethod().DeclaringType); 51 MethodBase.GetCurrentMethod().DeclaringType);
52 52
53 string m_ServerURL; 53 private string m_ServerURL;
54 private GridRegion m_Gatekeeper;
54 55
55 public UserAgentServiceConnector(string url) : this(url, true) 56 public UserAgentServiceConnector(string url) : this(url, true)
56 { 57 {
@@ -102,9 +103,15 @@ namespace OpenSim.Services.Connectors.Hypergrid
102 m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL); 103 m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL);
103 } 104 }
104 105
106 protected override string AgentPath()
107 {
108 return "homeagent/";
109 }
105 110
106 // The Login service calls this interface with a non-null [client] ipaddress 111 // The Login service calls this interface with fromLogin=true
107 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress, out string reason) 112 // Sims call it with fromLogin=false
113 // Either way, this is verified by the handler
114 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, bool fromLogin, out string reason)
108 { 115 {
109 reason = String.Empty; 116 reason = String.Empty;
110 117
@@ -115,119 +122,34 @@ namespace OpenSim.Services.Connectors.Hypergrid
115 return false; 122 return false;
116 } 123 }
117 124
118 string uri = m_ServerURL + "homeagent/" + aCircuit.AgentID + "/"; 125 GridRegion home = new GridRegion();
119 126 home.ServerURI = m_ServerURL;
120 Console.WriteLine(" >>> LoginAgentToGrid <<< " + uri); 127 home.RegionID = destination.RegionID;
121 128 home.RegionLocX = destination.RegionLocX;
122 HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); 129 home.RegionLocY = destination.RegionLocY;
123 AgentCreateRequest.Method = "POST";
124 AgentCreateRequest.ContentType = "application/json";
125 AgentCreateRequest.Timeout = 10000;
126 //AgentCreateRequest.KeepAlive = false;
127 //AgentCreateRequest.Headers.Add("Authorization", authKey);
128
129 // Fill it in
130 OSDMap args = PackCreateAgentArguments(aCircuit, gatekeeper, destination, ipaddress);
131
132 string strBuffer = "";
133 byte[] buffer = new byte[1];
134 try
135 {
136 strBuffer = OSDParser.SerializeJsonString(args);
137 Encoding str = Util.UTF8;
138 buffer = str.GetBytes(strBuffer);
139
140 }
141 catch (Exception e)
142 {
143 m_log.WarnFormat("[USER AGENT CONNECTOR]: Exception thrown on serialization of ChildCreate: {0}", e.Message);
144 // ignore. buffer will be empty, caller should check.
145 }
146
147 Stream os = null;
148 try
149 { // send the Post
150 AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send
151 os = AgentCreateRequest.GetRequestStream();
152 os.Write(buffer, 0, strBuffer.Length); //Send it
153 m_log.InfoFormat("[USER AGENT CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}",
154 uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY);
155 }
156 //catch (WebException ex)
157 catch
158 {
159 //m_log.InfoFormat("[USER AGENT CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message);
160 reason = "cannot contact remote region";
161 return false;
162 }
163 finally
164 {
165 if (os != null)
166 os.Close();
167 }
168
169 // Let's wait for the response
170 //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
171 130
172 try 131 m_Gatekeeper = gatekeeper;
173 {
174 using (WebResponse webResponse = AgentCreateRequest.GetResponse())
175 {
176 if (webResponse == null)
177 {
178 m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post");
179 }
180 else
181 {
182 using (Stream s = webResponse.GetResponseStream())
183 {
184 using (StreamReader sr = new StreamReader(s))
185 {
186 string response = sr.ReadToEnd().Trim();
187 m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
188
189 if (!String.IsNullOrEmpty(response))
190 {
191 try
192 {
193 // we assume we got an OSDMap back
194 OSDMap r = Util.GetOSDMap(response);
195 bool success = r["success"].AsBoolean();
196 reason = r["reason"].AsString();
197 return success;
198 }
199 catch (NullReferenceException e)
200 {
201 m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
202
203 // check for old style response
204 if (response.ToLower().StartsWith("true"))
205 return true;
206
207 return false;
208 }
209 }
210 }
211 }
212 }
213 }
214 }
215 catch (WebException ex)
216 {
217 m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message);
218 reason = "Destination did not reply";
219 return false;
220 }
221 132
222 return true; 133 Console.WriteLine(" >>> LoginAgentToGrid <<< " + home.ServerURI);
223 134
135 uint flags = fromLogin ? (uint)TeleportFlags.ViaLogin : (uint)TeleportFlags.ViaHome;
136 return CreateAgent(home, aCircuit, flags, out reason);
224 } 137 }
225 138
226 139
227 // The simulators call this interface 140 // The simulators call this interface
228 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason) 141 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason)
229 { 142 {
230 return LoginAgentToGrid(aCircuit, gatekeeper, destination, null, out reason); 143 return LoginAgentToGrid(aCircuit, gatekeeper, destination, false, out reason);
144 }
145
146 protected override void PackData(OSDMap args, AgentCircuitData aCircuit, GridRegion destination, uint flags)
147 {
148 base.PackData(args, aCircuit, destination, flags);
149 args["gatekeeper_serveruri"] = OSD.FromString(m_Gatekeeper.ServerURI);
150 args["gatekeeper_host"] = OSD.FromString(m_Gatekeeper.ExternalHostName);
151 args["gatekeeper_port"] = OSD.FromString(m_Gatekeeper.HttpPort.ToString());
152 args["destination_serveruri"] = OSD.FromString(destination.ServerURI);
231 } 153 }
232 154
233 protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress) 155 protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress)
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index ef2494a..da77719 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -79,11 +79,27 @@ namespace OpenSim.Services.Connectors.Simulation
79 return "agent/"; 79 return "agent/";
80 } 80 }
81 81
82 protected virtual void PackData(OSDMap args, AgentCircuitData aCircuit, GridRegion destination, uint flags)
83 {
84 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
85 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
86 args["destination_name"] = OSD.FromString(destination.RegionName);
87 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
88 args["teleport_flags"] = OSD.FromString(flags.ToString());
89 }
90
82 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) 91 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason)
83 { 92 {
84 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent start"); 93 string tmp = String.Empty;
85 94 return CreateAgent(destination, aCircuit, flags, out tmp, out reason);
95 }
96
97 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason)
98 {
99 m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI);
86 reason = String.Empty; 100 reason = String.Empty;
101 myipaddress = String.Empty;
102
87 if (destination == null) 103 if (destination == null)
88 { 104 {
89 reason = "Destination not found"; 105 reason = "Destination not found";
@@ -96,12 +112,7 @@ namespace OpenSim.Services.Connectors.Simulation
96 try 112 try
97 { 113 {
98 OSDMap args = aCircuit.PackAgentCircuitData(); 114 OSDMap args = aCircuit.PackAgentCircuitData();
99 115 PackData(args, aCircuit, destination, flags);
100 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
101 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
102 args["destination_name"] = OSD.FromString(destination.RegionName);
103 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
104 args["teleport_flags"] = OSD.FromString(flags.ToString());
105 116
106 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000); 117 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000);
107 bool success = result["success"].AsBoolean(); 118 bool success = result["success"].AsBoolean();
@@ -111,6 +122,7 @@ namespace OpenSim.Services.Connectors.Simulation
111 122
112 reason = data["reason"].AsString(); 123 reason = data["reason"].AsString();
113 success = data["success"].AsBoolean(); 124 success = data["success"].AsBoolean();
125 myipaddress = data["your_ip"].AsString();
114 return success; 126 return success;
115 } 127 }
116 128
@@ -125,6 +137,7 @@ namespace OpenSim.Services.Connectors.Simulation
125 137
126 reason = data["reason"].AsString(); 138 reason = data["reason"].AsString();
127 success = data["success"].AsBoolean(); 139 success = data["success"].AsBoolean();
140 myipaddress = data["your_ip"].AsString();
128 m_log.WarnFormat( 141 m_log.WarnFormat(
129 "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName); 142 "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName);
130 return success; 143 return success;
@@ -229,7 +242,7 @@ namespace OpenSim.Services.Connectors.Simulation
229 /// </summary> 242 /// </summary>
230 private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, int timeout) 243 private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, int timeout)
231 { 244 {
232 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent start"); 245 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent in {0}", destination.ServerURI);
233 246
234 // Eventually, we want to use a caps url instead of the agentID 247 // Eventually, we want to use a caps url instead of the agentID
235 string uri = destination.ServerURI + AgentPath() + cAgentData.AgentID + "/"; 248 string uri = destination.ServerURI + AgentPath() + cAgentData.AgentID + "/";