30 using System.Collections;
31 using System.Collections.Generic;
34 using System.Reflection;
37 using OpenSim.Framework;
39 using OpenSim.Services.Interfaces;
41 using OpenMetaverse.StructuredData;
45 namespace OpenSim.Services.Connectors
49 private static readonly ILog m_log =
51 MethodBase.GetCurrentMethod().DeclaringType);
61 Initialise(gridServices);
66 m_GridService = gridServices;
72 Util.RegionHandleToWorldLoc(regionHandle, out x, out y);
73 GridRegion regInfo = m_GridService.GetRegionByPosition(thisRegion.ScopeID, (int)x, (
int)y);
74 if ((regInfo != null) &&
76 !((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.
HttpPort)))
78 if (!DoHelloNeighbourCall(regInfo, thisRegion))
89 string uri = region.ServerURI +
"region/" + thisRegion.RegionID +
"/";
92 WebRequest helloNeighbourRequest;
96 helloNeighbourRequest = WebRequest.Create(uri);
100 m_log.Warn(string.Format(
101 "[NEIGHBOUR SERVICES CONNECTOR]: Unable to parse uri {0} to send HelloNeighbour from {1} to {2}. Exception {3} ",
102 uri, thisRegion.RegionName, region.RegionName, e.Message), e);
107 helloNeighbourRequest.Method =
"POST";
108 helloNeighbourRequest.ContentType =
"application/json";
109 helloNeighbourRequest.Timeout = 10000;
115 args = thisRegion.PackRegionInfoData();
119 m_log.Warn(string.Format(
120 "[NEIGHBOUR SERVICES CONNECTOR]: PackRegionInfoData failed for HelloNeighbour from {0} to {1}. Exception {2} ",
121 thisRegion.RegionName, region.RegionName, e.Message), e);
127 args[
"destination_handle"] = OSD.FromString(region.RegionHandle.ToString());
129 string strBuffer =
"";
130 byte[] buffer =
new byte[1];
134 strBuffer = OSDParser.SerializeJsonString(args);
135 buffer = Util.UTF8NoBomEncoding.GetBytes(strBuffer);
139 m_log.Warn(string.Format(
140 "[NEIGHBOUR SERVICES CONNECTOR]: Exception thrown on serialization of HelloNeighbour from {0} to {1}. Exception {2} ",
141 thisRegion.RegionName, region.RegionName, e.Message), e);
149 helloNeighbourRequest.ContentLength = buffer.Length;
150 os = helloNeighbourRequest.GetRequestStream();
151 os.Write(buffer, 0, strBuffer.Length);
173 using (WebResponse webResponse = helloNeighbourRequest.GetResponse())
175 if (webResponse == null)
178 "[NEIGHBOUR SERVICES CONNECTOR]: Null reply on DoHelloNeighbourCall post from {0} to {1}",
179 thisRegion.RegionName, region.RegionName);
182 using (Stream s = webResponse.GetResponseStream())
184 using (StreamReader sr =
new StreamReader(s))
187 sr.ReadToEnd().Trim();
195 m_log.Warn(string.Format(
196 "[NEIGHBOUR SERVICES CONNECTOR]: Exception on reply of DoHelloNeighbourCall from {0} back to {1}. Exception {2} ",
197 region.RegionName, thisRegion.RegionName, e.Message), e);
virtual void Initialise(IGridService gridServices)
uint HttpPort
The port by which http communication occurs with the region (most noticeably, CAPS communication) ...
OpenMetaverse.StructuredData.OSDMap OSDMap
OpenSim.Services.Interfaces.GridRegion GridRegion
NeighbourServicesConnector(IGridService gridServices)
bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion)
NeighbourServicesConnector()
virtual GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)