本文整理汇总了C#中OpenSim.Services.Interfaces.GridRegion.FromOSD方法的典型用法代码示例。如果您正苦于以下问题:C# GridRegion.FromOSD方法的具体用法?C# GridRegion.FromOSD怎么用?C# GridRegion.FromOSD使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenSim.Services.Interfaces.GridRegion
的用法示例。
在下文中一共展示了GridRegion.FromOSD方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterRegion
public virtual string RegisterRegion(GridRegion regionInfo, UUID SecureSessionID, out UUID SessionID,
out List<GridRegion> neighbors)
{
neighbors = new List<GridRegion>();
OSDMap map = new OSDMap();
map["Region"] = regionInfo.ToOSD();
map["SecureSessionID"] = SecureSessionID;
map["Method"] = "Register";
List<string> serverURIs =
m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf("RegistrationURI");
foreach (string mServerUri in serverURIs)
{
OSDMap result = WebUtils.PostToService(mServerUri + "/grid", map, true, false);
if (result["Success"].AsBoolean())
{
try
{
OSD r = OSDParser.DeserializeJson(result["_RawResult"]);
if (r is OSDMap)
{
OSDMap innerresult = (OSDMap) r;
if (innerresult["Result"].AsString() == "")
{
object[] o = new object[2];
o[0] = regionInfo;
o[1] = innerresult;
SessionID = innerresult["SecureSessionID"].AsUUID();
m_registry.RequestModuleInterface<IConfigurationService>().AddNewUrls(regionInfo.RegionHandle.ToString(), (OSDMap) innerresult["URLs"]);
OSDArray array = (OSDArray) innerresult["Neighbors"];
foreach (OSD ar in array)
{
GridRegion n = new GridRegion();
n.FromOSD((OSDMap) ar);
neighbors.Add(n);
}
m_registry.RequestModuleInterface<ISimulationBase>().EventManager.FireGenericEventHandler("GridRegionRegistered", o);
return "";
}
else
{
SessionID = UUID.Zero;
return innerresult["Result"].AsString();
}
}
}
catch (Exception) //JsonException
{
MainConsole.Instance.Warn("[GridServiceConnector]: Exception on parsing OSDMap from server, legacy (OpenSim) server?");
}
}
}
SessionID = SecureSessionID;
return OldRegisterRegion(regionInfo);
}
示例2: NewRegister
private byte[] NewRegister(OSDMap request)
{
GridRegion rinfo = new GridRegion();
rinfo.FromOSD((OSDMap) request["Region"]);
UUID SecureSessionID = request["SecureSessionID"].AsUUID();
string result = "";
List<GridRegion> neighbors = new List<GridRegion>();
if (rinfo != null)
result = m_GridService.RegisterRegion(rinfo, SecureSessionID, out SecureSessionID, out neighbors);
OSDMap resultMap = new OSDMap();
resultMap["SecureSessionID"] = SecureSessionID;
resultMap["Result"] = result;
if (result == "")
{
object[] o = new object[3] {resultMap, SecureSessionID, rinfo};
m_registry.RequestModuleInterface<ISimulationBase>().EventManager.FireGenericEventHandler(
"GridRegionSuccessfullyRegistered", o);
//Send the neighbors as well
OSDArray array = new OSDArray();
foreach (GridRegion r in neighbors)
{
array.Add(r.ToOSD());
}
resultMap["Neighbors"] = array;
}
return Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(resultMap));
}
示例3: DoTeleport
public virtual void DoTeleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags)
{
sp.ControllingClient.SendTeleportProgress(teleportFlags, "sending_dest");
if (finalDestination == null)
{
sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
return;
}
MainConsole.Instance.DebugFormat(
"[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}/{2}",
finalDestination.ServerURI, finalDestination.RegionName, position);
sp.ControllingClient.SendTeleportProgress(teleportFlags, "arriving");
sp.SetAgentLeaving(finalDestination);
// Fixing a bug where teleporting while sitting results in the avatar ending up removed from
// both regions
if (sp.ParentID != UUID.Zero)
sp.StandUp();
AgentCircuitData agentCircuit = BuildCircuitDataForPresence(sp, position);
AgentData agent = new AgentData();
sp.CopyTo(agent);
//Fix the position
agent.Position = position;
IEventQueueService eq = sp.Scene.RequestModuleInterface<IEventQueueService>();
if (eq != null)
{
ISyncMessagePosterService syncPoster = sp.Scene.RequestModuleInterface<ISyncMessagePosterService>();
if (syncPoster != null)
{
//This does CreateAgent and sends the EnableSimulator/EstablishAgentCommunication/TeleportFinish
// messages if they need to be called and deals with the callback
syncPoster.Get(SyncMessageHelper.TeleportAgent((int)sp.DrawDistance,
agentCircuit, agent, teleportFlags, finalDestination, sp.Scene.RegionInfo.RegionHandle),
sp.UUID, sp.Scene.RegionInfo.RegionHandle, (map) =>
{
if (map == null || !map["success"].AsBoolean())
{
// Fix the agent status
sp.IsChildAgent = false;
//Tell modules about it
sp.AgentFailedToLeave();
sp.ControllingClient.SendTeleportFailed(map != null
? map["Reason"].AsString()
: "Teleport Failed");
return;
}
//Get the new destintation, it may have changed
if (map.ContainsKey("Destination"))
{
finalDestination = new GridRegion();
finalDestination.FromOSD((OSDMap)map["Destination"]);
}
MakeChildAgent(sp, finalDestination, false);
});
}
}
}
示例4: OnMessageReceived
//.........这里部分代码省略.........
}
else if (message["Method"] == "CancelTeleport")
{
if (regionCaps == null || clientCaps == null)
return null;
//Only the region the client is root in can do this
IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService ();
if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle)
{
//The user has requested to cancel the teleport, stop them.
clientCaps.RequestToCancelTeleport = true;
regionCaps.Disabled = false;
}
}
else if (message["Method"] == "AgentLoggedOut")
{
//ONLY if the agent is root do we even consider it
if (regionCaps != null)
{
if (regionCaps.RootAgent)
{
LogoutAgent(regionCaps);
}
}
}
else if (message["Method"] == "SendChildAgentUpdate")
{
if (regionCaps == null || clientCaps == null)
return null;
IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService ();
if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle)
{
OSDMap body = ((OSDMap)message["Message"]);
AgentPosition pos = new AgentPosition();
pos.Unpack((OSDMap)body["AgentPos"]);
SendChildAgentUpdate(pos, regionCaps);
regionCaps.Disabled = false;
}
}
else if (message["Method"] == "TeleportAgent")
{
if (regionCaps == null || clientCaps == null)
return null;
IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService ();
if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle)
{
OSDMap body = ((OSDMap)message["Message"]);
GridRegion destination = new GridRegion();
destination.FromOSD((OSDMap)body["Region"]);
uint TeleportFlags = body["TeleportFlags"].AsUInteger();
int DrawDistance = body["DrawDistance"].AsInteger();
AgentCircuitData Circuit = new AgentCircuitData();
Circuit.UnpackAgentCircuitData((OSDMap)body["Circuit"]);
AgentData AgentData = new AgentData();
AgentData.Unpack((OSDMap)body["AgentData"]);
regionCaps.Disabled = false;
OSDMap result = new OSDMap();
string reason = "";
result["Success"] = TeleportAgent(destination, TeleportFlags, DrawDistance,
Circuit, AgentData, AgentID, requestingRegion, out reason);
result["Reason"] = reason;
return result;
}
}
else if (message["Method"] == "CrossAgent")
{
if (regionCaps == null || clientCaps == null)
return null;
if (clientCaps.GetRootCapsService().RegionHandle == regionCaps.RegionHandle)
{
//This is a simulator message that tells us to cross the agent
OSDMap body = ((OSDMap)message["Message"]);
Vector3 pos = body["Pos"].AsVector3();
Vector3 Vel = body["Vel"].AsVector3();
GridRegion Region = new GridRegion();
Region.FromOSD((OSDMap)body["Region"]);
AgentCircuitData Circuit = new AgentCircuitData();
Circuit.UnpackAgentCircuitData((OSDMap)body["Circuit"]);
AgentData AgentData = new AgentData();
AgentData.Unpack((OSDMap)body["AgentData"]);
regionCaps.Disabled = false;
OSDMap result = new OSDMap();
string reason = "";
result["Success"] = CrossAgent(Region, pos, Vel, Circuit, AgentData,
AgentID, requestingRegion, out reason);
result["Reason"] = reason;
return result;
}
}
return null;
}
示例5: DoTeleport
public virtual void DoTeleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags)
{
sp.ControllingClient.SendTeleportProgress(teleportFlags, "sending_dest");
if (finalDestination == null)
{
sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
return;
}
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}/{2}",
finalDestination.ServerURI, finalDestination.RegionName, position);
sp.ControllingClient.SendTeleportProgress(teleportFlags, "arriving");
// Fixing a bug where teleporting while sitting results in the avatar ending up removed from
// both regions
if (sp.ParentID != UUID.Zero)
sp.StandUp();
//Make sure that all attachments are ready for the teleport
IAttachmentsModule attModule = sp.Scene.RequestModuleInterface<IAttachmentsModule>();
if (attModule != null)
attModule.ValidateAttachments(sp.UUID);
AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();
agentCircuit.startpos = position;
//The agent will be a root agent
agentCircuit.child = false;
//Make sure the appearnace is right
IAvatarAppearanceModule appearance = sp.RequestModuleInterface<IAvatarAppearanceModule> ();
if(appearance != null)
agentCircuit.Appearance = appearance.Appearance;
AgentData agent = new AgentData();
sp.CopyTo(agent);
//Fix the position
agent.Position = position;
IEventQueueService eq = sp.Scene.RequestModuleInterface<IEventQueueService>();
if (eq != null)
{
ISyncMessagePosterService syncPoster = sp.Scene.RequestModuleInterface<ISyncMessagePosterService>();
if (syncPoster != null)
{
AgentCircuitData oldCircuit = sp.Scene.AuthenticateHandler.AgentCircuitsByUUID[sp.UUID];
agentCircuit.ServiceURLs = oldCircuit.ServiceURLs;
agentCircuit.firstname = oldCircuit.firstname;
agentCircuit.lastname = oldCircuit.lastname;
agentCircuit.ServiceSessionID = oldCircuit.ServiceSessionID;
//This does CreateAgent and sends the EnableSimulator/EstablishAgentCommunication/TeleportFinish
// messages if they need to be called and deals with the callback
OSDMap map = syncPoster.Get(SyncMessageHelper.TeleportAgent((int)sp.DrawDistance,
agentCircuit, agent, teleportFlags, finalDestination, sp.Scene.RegionInfo.RegionHandle),
sp.UUID, sp.Scene.RegionInfo.RegionHandle);
bool result = false;
if(map != null)
result = map["Success"].AsBoolean();
if (!result)
{
// Fix the agent status
sp.IsChildAgent = false;
//Fix user's attachments
attModule.RezAttachments (sp);
if (map != null)
sp.ControllingClient.SendTeleportFailed (map["Reason"].AsString ());
else
sp.ControllingClient.SendTeleportFailed ("Teleport Failed");
return;
}
else
{
//Get the new destintation, it may have changed
if(map.ContainsKey("Destination"))
{
finalDestination = new GridRegion();
finalDestination.FromOSD((OSDMap)map["Destination"]);
}
}
}
}
MakeChildAgent(sp, finalDestination);
}
示例6: Duplicate
public override IDataTransferable Duplicate()
{
GridRegion m = new GridRegion();
m.FromOSD(ToOSD());
return m;
}
示例7: NewRegister
private byte[] NewRegister(OSDMap request)
{
GridRegion rinfo = new GridRegion();
rinfo.FromOSD((OSDMap)request["Region"]);
UUID SecureSessionID = request["SecureSessionID"].AsUUID();
string result = "";
if (rinfo != null)
result = m_GridService.RegisterRegion(rinfo, SecureSessionID, out SecureSessionID);
OSDMap resultMap = new OSDMap();
resultMap["SecureSessionID"] = SecureSessionID;
resultMap["Result"] = result;
if (result == "")
{
//Remove any previous URLs
m_registry.RequestModuleInterface<IGridRegistrationService>().RemoveUrlsForClient(SecureSessionID.ToString(), rinfo.RegionHandle);
OSDMap urls = m_registry.RequestModuleInterface<IGridRegistrationService>().GetUrlForRegisteringClient(SecureSessionID.ToString(), rinfo.RegionHandle);
resultMap["URLs"] = urls;
resultMap["TimeBeforeReRegister"] = m_registry.RequestModuleInterface<IGridRegistrationService>().ExpiresTime;
}
return Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(resultMap));
}
示例8: DoTeleport
public virtual void DoTeleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags)
{
sp.ControllingClient.SendTeleportProgress(teleportFlags, "sending_dest");
if (finalDestination == null)
{
sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
return;
}
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}/{2}",
finalDestination.ServerURI, finalDestination.RegionName, position);
sp.ControllingClient.SendTeleportProgress(teleportFlags, "arriving");
// Fixing a bug where teleporting while sitting results in the avatar ending up removed from
// both regions
if (sp.ParentID != UUID.Zero)
sp.StandUp();
//Make sure that all attachments are ready for the teleport
IAttachmentsModule attModule = sp.Scene.RequestModuleInterface<IAttachmentsModule>();
if (attModule != null)
attModule.ValidateAttachments(sp.UUID);
AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();
agentCircuit.startpos = position;
//The agent will be a root agent
agentCircuit.child = false;
//Make sure the appearnace is right
IAvatarAppearanceModule appearance = sp.RequestModuleInterface<IAvatarAppearanceModule> ();
agentCircuit.Appearance = appearance.Appearance;
AgentData agent = new AgentData();
sp.CopyTo(agent);
//Fix the position
agent.Position = position;
IEventQueueService eq = sp.Scene.RequestModuleInterface<IEventQueueService>();
if (eq != null)
{
ISyncMessagePosterService syncPoster = sp.Scene.RequestModuleInterface<ISyncMessagePosterService>();
if (syncPoster != null)
{
AgentCircuitData oldCircuit = sp.Scene.AuthenticateHandler.AgentCircuitsByUUID[sp.UUID];
agentCircuit.ServiceURLs = oldCircuit.ServiceURLs;
agentCircuit.firstname = oldCircuit.firstname;
agentCircuit.lastname = oldCircuit.lastname;
agentCircuit.ServiceSessionID = oldCircuit.ServiceSessionID;
//This does CreateAgent and sends the EnableSimulator/EstablishAgentCommunication/TeleportFinish
// messages if they need to be called and deals with the callback
OSDMap map = syncPoster.Get(SyncMessageHelper.TeleportAgent((int)sp.DrawDistance,
agentCircuit, agent, teleportFlags, finalDestination, sp.Scene.RegionInfo.RegionHandle),
sp.UUID, sp.Scene.RegionInfo.RegionHandle);
bool result = false;
if(map != null)
result = map["Success"].AsBoolean();
if (!result)
{
// Fix the agent status
sp.IsChildAgent = false;
//Fix user's attachments
attModule.RezAttachments (sp);
if (map != null)
sp.ControllingClient.SendTeleportFailed (map["Reason"].AsString ());
else
sp.ControllingClient.SendTeleportFailed ("Teleport Failed");
return;
}
else
{
//Get the new destintation, it may have changed
finalDestination = new GridRegion ();
finalDestination.FromOSD ((OSDMap)map["Destination"]);
if(string.IsNullOrEmpty(finalDestination.ServerURI))//Fix the serverURL
finalDestination.ServerURI = (finalDestination.ExternalHostName.StartsWith("http://") ?
finalDestination.ExternalHostName :
("http://" + finalDestination.ExternalHostName)) +
":" + finalDestination.HttpPort;
}
}
}
sp.Scene.AuroraEventManager.FireGenericEventHandler ("SendingAttachments", new object[2] { finalDestination, sp });
//Kill the groups here, otherwise they will become ghost attachments
// and stay in the sim, they'll get readded below into the new sim
KillAttachments(sp);
// Well, this is it. The agent is over there.
KillEntity(sp.Scene, sp);
//Make it a child agent for now... the grid will kill us later if we need to close
sp.MakeChildAgent(finalDestination);
}
示例9: Enqueue
/// <summary>
/// Add the given event into the client's queue so that it is sent on the next
/// </summary>
/// <param name="ev"></param>
/// <param name="avatarID"></param>
/// <returns></returns>
public bool Enqueue(OSD ev)
{
try
{
if (ev == null)
return false;
//Check the messages to pull out ones that are creating or destroying CAPS in this or other regions
if (ev.Type == OSDType.Map)
{
OSDMap map = (OSDMap)ev;
if (map.ContainsKey("message") && map["message"] == "DisableSimulator")
{
//Let this pass through, after the next event queue pass we can remove it
//m_service.ClientCaps.RemoveCAPS(m_service.RegionHandle);
}
else if (map.ContainsKey("message") && map["message"] == "EnableChildAgents")
{
//Some notes on this message:
// 1) This is a region > CapsService message ONLY, this should never be sent to the client!
// 2) This just enables child agents in the regions given, as the region cannot do it,
// as regions do not have the ability to know what Cap Urls other regions have.
// 3) We could do more checking here, but we don't really 'have' to at this point.
// If the sim was able to get it past the password checks and everything,
// it should be able to add the neighbors here. We could do the neighbor finding here
// as well, but it's not necessary at this time.
OSDMap body = ((OSDMap)map["body"]);
//Parse the OSDMap
int DrawDistance = body["DrawDistance"].AsInteger();
AgentCircuitData circuitData = new AgentCircuitData();
circuitData.UnpackAgentCircuitData((OSDMap)body["Circuit"]);
OSDArray neighborsArray = (OSDArray)body["Regions"];
GridRegion[] neighbors = new GridRegion[neighborsArray.Count];
int i = 0;
foreach (OSD r in neighborsArray)
{
GridRegion region = new GridRegion();
region.FromOSD((OSDMap)r);
neighbors[i] = region;
i++;
}
uint TeleportFlags = body["TeleportFlags"].AsUInteger();
AgentData data = null;
if (body.ContainsKey("AgentData"))
{
data = new AgentData();
data.Unpack((OSDMap)body["AgentData"]);
}
byte[] IPAddress = null;
if(body.ContainsKey("IPAddress"))
IPAddress = body["IPAddress"].AsBinary();
int Port = 0;
if (body.ContainsKey("Port"))
Port = body["Port"].AsInteger();
//Now do the creation
//Don't send it to the client at all, so return here
return EnableChildAgents(DrawDistance, neighbors, circuitData, TeleportFlags, data,
IPAddress, Port);
}
else if (map.ContainsKey("message") && map["message"] == "EstablishAgentCommunication")
{
string SimSeedCap = ((OSDMap)map["body"])["seed-capability"].AsString();
ulong regionHandle = ((OSDMap)map["body"])["region-handle"].AsULong();
string newSeedCap = CapsUtil.GetCapsSeedPath(CapsUtil.GetRandomCapsObjectPath());
IRegionClientCapsService otherRegionService = m_service.ClientCaps.GetOrCreateCapsService(regionHandle, newSeedCap, SimSeedCap);
//ONLY UPDATE THE SIM SEED HERE
//DO NOT PASS THE newSeedCap FROM ABOVE AS IT WILL BREAK THIS CODE
// AS THE CLIENT EXPECTS THE SAME CAPS SEED IF IT HAS BEEN TO THE REGION BEFORE
// AND FORCE UPDATING IT HERE WILL BREAK IT.
otherRegionService.AddSEEDCap("", SimSeedCap, otherRegionService.Password);
((OSDMap)map["body"])["seed-capability"] = otherRegionService.CapsUrl;
}
else if (map.ContainsKey("message") && map["message"] == "CrossedRegion")
{
OSDMap infoMap = ((OSDMap)((OSDArray)((OSDMap)map["body"])["RegionData"])[0]);
string SimSeedCap = infoMap["SeedCapability"].AsString();
ulong regionHandle = infoMap["RegionHandle"].AsULong();
string newSeedCap = CapsUtil.GetCapsSeedPath(CapsUtil.GetRandomCapsObjectPath());
IRegionClientCapsService otherRegionService = m_service.ClientCaps.GetOrCreateCapsService(regionHandle, newSeedCap, SimSeedCap);
//ONLY UPDATE THE SIM SEED HERE
//DO NOT PASS THE newSeedCap FROM ABOVE AS IT WILL BREAK THIS CODE
// AS THE CLIENT EXPECTS THE SAME CAPS SEED IF IT HAS BEEN TO THE REGION BEFORE
// AND FORCE UPDATING IT HERE WILL BREAK IT.
otherRegionService.AddSEEDCap("", SimSeedCap, otherRegionService.Password);
//.........这里部分代码省略.........
示例10: FromOSD
public override void FromOSD(OSDMap map)
{
Error = map["Error"];
OSDArray n = (OSDArray)map["Neighbors"];
Neighbors = n.ConvertAll<GridRegion>((osd) => { GridRegion r = new GridRegion(); r.FromOSD((OSDMap)osd); return r; });
SessionID = map["SessionID"];
RegionFlags = map["RegionFlags"];
if (map.ContainsKey("Urls"))
Urls = (OSDMap)map["Urls"];
if (map.ContainsKey("RegionRemote"))
RegionRemote = (OSDMap)map["RegionRemote"];
if (map.ContainsKey("Region"))
{
Region = new GridRegion();
Region.FromOSD((OSDMap)map["Region"]);
}
}
示例11: LoginAgentToGrid
public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint clientIP, out string reason)
{
m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} (@{1}) to grid {2}",
agentCircuit.AgentID, ((clientIP == null) ? "stored IP" : clientIP.Address.ToString()),
gatekeeper.ExternalHostName +":"+ gatekeeper.HttpPort);
// Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination
GridRegion region = new GridRegion();
region.FromOSD(gatekeeper.ToOSD());
region.RegionName = finalDestination.RegionName;
region.RegionID = finalDestination.RegionID;
region.RegionLocX = finalDestination.RegionLocX;
region.RegionLocY = finalDestination.RegionLocY;
// Generate a new service session
agentCircuit.ServiceSessionID = "http://" + region.ExternalHostName + ":" + region.HttpPort + ";" + UUID.Random();
TravelingAgentInfo old = UpdateTravelInfo(agentCircuit, region);
bool success = false;
string myExternalIP = string.Empty;
string gridName = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort;
if (m_GridName == gridName)
success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, null, out reason);
else
success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out myExternalIP, out reason);
if (!success)
{
m_log.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} to grid {1}, reason: {2}",
agentCircuit.AgentID, region.ExternalHostName + ":" + region.HttpPort, reason);
// restore the old travel info
lock (m_TravelingAgents)
m_TravelingAgents[agentCircuit.SessionID] = old;
return false;
}
m_log.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP);
// else set the IP addresses associated with this client
if (clientIP != null)
m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress = clientIP.Address.ToString();
m_TravelingAgents[agentCircuit.SessionID].MyIpAddress = myExternalIP;
return true;
}
示例12: Handle
public override byte[] Handle(string path, Stream requestData,
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{
StreamReader sr = new StreamReader (requestData);
string body = sr.ReadToEnd ();
sr.Close ();
body = body.Trim ();
//MainConsole.Instance.DebugFormat("[XXX]: query String: {0}", body);
OSDMap map = (OSDMap)OSDParser.DeserializeJson (body);
GridRegion reg = new GridRegion ();
switch (map["Method"].AsString())
{
case "RegionOnline":
reg.FromOSD((OSDMap)map["Region"]);
m_manager.AddRegion (reg, map["URL"]);
break;
case "RegionProvided":
reg.FromOSD ((OSDMap)map["Region"]);
m_manager.AddAllRegion (reg, map["URL"]);
break;
case "RegionOffline":
reg.FromOSD ((OSDMap)map["Region"]);
m_manager.RemoveRegion (reg);
break;
default:
break;
}
return new byte[0];
}
示例13: Enqueue
/// <summary>
/// Add the given event into the client's queue so that it is sent on the next
/// </summary>
/// <param name="ev"></param>
/// <param name="avatarID"></param>
/// <returns></returns>
public bool Enqueue(OSD ev)
{
try
{
if (ev == null)
return false;
//Check the messages to pull out ones that are creating or destroying CAPS in this or other regions
if (ev.Type == OSDType.Map)
{
OSDMap map = (OSDMap)ev;
if (map.ContainsKey("message") && map["message"] == "DisableSimulator")
{
//Let this pass through, after the next event queue pass we can remove it
//m_service.ClientCaps.RemoveCAPS(m_service.RegionHandle);
if (!m_service.Disabled)
{
m_service.Disabled = true;
OSDMap body = ((OSDMap)map["body"]);
//See whether this needs sent to the client or not
if (!body["KillClient"].AsBoolean())
{
//This is very risky... but otherwise the user doesn't get cleaned up...
m_service.ClientCaps.RemoveCAPS(m_service.RegionHandle);
return true;
}
}
else //Don't enqueue multiple times
return true;
}
else if (map.ContainsKey("message") && map["message"] == "ArrivedAtDestination")
{
//Recieved a callback
m_service.ClientCaps.CallbackHasCome = true;
m_service.Disabled = false;
//Don't send it to the client
return true;
}
else if (map.ContainsKey("message") && map["message"] == "CancelTeleport")
{
//The user has requested to cancel the teleport, stop them.
m_service.ClientCaps.RequestToCancelTeleport = true;
m_service.Disabled = false;
//Don't send it to the client
return true;
}
else if (map.ContainsKey("message") && map["message"] == "SendChildAgentUpdate")
{
OSDMap body = ((OSDMap)map["body"]);
AgentPosition pos = new AgentPosition();
pos.Unpack((OSDMap)body["AgentPos"]);
UUID region = body["Region"].AsUUID();
SendChildAgentUpdate(pos, region);
m_service.Disabled = false;
//Don't send to the client
return true;
}
else if (map.ContainsKey("message") && map["message"] == "TeleportAgent")
{
OSDMap body = ((OSDMap)map["body"]);
GridRegion destination = new GridRegion();
destination.FromOSD((OSDMap)body["Region"]);
uint TeleportFlags = body["TeleportFlags"].AsUInteger();
int DrawDistance = body["DrawDistance"].AsInteger();
AgentCircuitData Circuit = new AgentCircuitData();
Circuit.UnpackAgentCircuitData((OSDMap)body["Circuit"]);
AgentData AgentData = new AgentData();
AgentData.Unpack((OSDMap)body["AgentData"]);
m_service.Disabled = false;
//Don't send to the client
return TeleportAgent(destination, TeleportFlags, DrawDistance, Circuit, AgentData);
}
else if (map.ContainsKey("message") && map["message"] == "CrossAgent")
{
//This is a simulator message that tells us to cross the agent
OSDMap body = ((OSDMap)map["body"]);
Vector3 pos = body["Pos"].AsVector3();
Vector3 Vel = body["Vel"].AsVector3();
GridRegion Region = new GridRegion();
Region.FromOSD((OSDMap)body["Region"]);
AgentCircuitData Circuit = new AgentCircuitData();
Circuit.UnpackAgentCircuitData((OSDMap)body["Circuit"]);
AgentData AgentData = new AgentData();
AgentData.Unpack((OSDMap)body["AgentData"]);
//.........这里部分代码省略.........
示例14: FromOSD
public override void FromOSD(OSDMap map)
{
Error = map["Error"];
OSDArray n = (OSDArray)map["Neighbors"];
Neighbors = n.ConvertAll<GridRegion>((osd) => { GridRegion r = new GridRegion(); r.FromOSD((OSDMap)osd); return r; });
SessionID = map["SessionID"];
RegionFlags = map["RegionFlags"];
Urls = (OSDMap)map["Urls"];
}
示例15: UpdateMap
private byte[] UpdateMap(OSDMap request)
{
GridRegion rinfo = new GridRegion();
rinfo.FromOSD((OSDMap) request["Region"]);
UUID SecureSessionID = request["SecureSessionID"].AsUUID();
string result = "";
if (rinfo != null)
result = m_GridService.UpdateMap(rinfo, SecureSessionID);
OSDMap resultMap = new OSDMap();
resultMap["Result"] = result;
return Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(OSD.FromBoolean(true)));
}