本文整理汇总了C#中WhiteCore.Framework.Services.GridRegion类的典型用法代码示例。如果您正苦于以下问题:C# GridRegion类的具体用法?C# GridRegion怎么用?C# GridRegion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GridRegion类属于WhiteCore.Framework.Services命名空间,在下文中一共展示了GridRegion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAgent
/**
* Agent-related communications
*/
public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out CreateAgentResponse response)
{
response = new CreateAgentResponse();
IScene Scene = destination == null ? null : GetScene(destination.RegionID);
if (destination == null || Scene == null)
{
response.Reason = "Given destination was null";
response.Success = false;
return false;
}
if (Scene.RegionInfo.RegionID != destination.RegionID)
{
response.Reason = "Did not find region " + destination.RegionName;;
response.Success = false;
return false;
}
IEntityTransferModule transferModule = Scene.RequestModuleInterface<IEntityTransferModule>();
if (transferModule != null)
return transferModule.NewUserConnection(Scene, aCircuit, teleportFlags, out response);
response.Reason = "Did not find region " + destination.RegionName;
response.Success = false;
return false;
}
示例2: CloseAgent
public bool CloseAgent(GridRegion destination, UUID agentID)
{
CloseAgentRequest request = new CloseAgentRequest();
request.AgentID = agentID;
request.Destination = destination;
m_syncMessagePoster.Post(destination.ServerURI, request.ToOSD());
return true;
}
示例3: CloseAgent
public bool CloseAgent(GridRegion destination, UUID agentID)
{
IScene Scene = destination == null ? null : GetScene(destination.RegionID);
if (Scene == null || destination == null)
return false;
IEntityTransferModule transferModule = Scene.RequestModuleInterface<IEntityTransferModule>();
if (transferModule != null)
return transferModule.IncomingCloseAgent(Scene, agentID);
return false;
}
示例4: IsAuthorizedForRegion
public bool IsAuthorizedForRegion(GridRegion region, AgentCircuitData agent, bool isRootAgent, out string reason)
{
ISceneManager manager = m_registry.RequestModuleInterface<ISceneManager>();
IScene scene = manager == null ? null : manager.Scenes.Find((s) => s.RegionInfo.RegionID == region.RegionID);
if (scene != null)
{
//Found the region, check permissions
return scene.Permissions.AllowedIncomingAgent(agent, isRootAgent, out reason);
}
reason = "Not Authorized as region does not exist.";
return false;
}
示例5: IncomingCapsRequest
public void IncomingCapsRequest (UUID agentID, GridRegion region, ISimulationBase simbase, ref OSDMap capURLs)
{
m_syncMessage = simbase.ApplicationRegistry.RequestModuleInterface<ISyncMessagePosterService> ();
m_appearanceService = simbase.ApplicationRegistry.RequestModuleInterface<IAgentAppearanceService> ();
m_region = region;
m_agentID = agentID;
if (m_appearanceService == null)
return;//Can't bake!
m_uri = "/CAPS/UpdateAvatarAppearance/" + UUID.Random () + "/";
MainServer.Instance.AddStreamHandler (new GenericStreamHandler ("POST", m_uri, UpdateAvatarAppearance));
capURLs ["UpdateAvatarAppearance"] = MainServer.Instance.ServerURI + m_uri;
}
示例6: RemoveExternalCaps
public void RemoveExternalCaps(UUID agentID, GridRegion region)
{
OSDMap req = new OSDMap();
req["AgentID"] = agentID;
req["Region"] = region.ToOSD();
req["Method"] = "RemoveCaps";
foreach (string uri in m_servers)
m_syncPoster.Post(uri, req);
foreach (var h in GetHandlers(agentID, region.RegionID))
{
if (m_allowedCapsModules.Contains(h.Name))
h.IncomingCapsDestruction();
}
}
示例7: IncomingCapsRequest
public void IncomingCapsRequest (UUID agentID, GridRegion region, ISimulationBase simbase, ref OSDMap capURLs)
{
m_agentID = agentID;
m_region = region;
m_userScopeIDs = simbase.ApplicationRegistry.RequestModuleInterface<IUserAccountService> ().GetUserAccount (null, m_agentID).AllScopeIDs;
m_gridService = simbase.ApplicationRegistry.RequestModuleInterface<IGridService> ();
IConfig config = simbase.ConfigSource.Configs ["MapCAPS"];
if (config != null)
m_allowCapsMessage = config.GetBoolean ("AllowCapsMessage", m_allowCapsMessage);
HttpServerHandle method = (path, request, httpRequest, httpResponse) => MapLayerRequest (HttpServerHandlerHelpers.ReadString (request), httpRequest, httpResponse);
m_uri = "/CAPS/MapLayer/" + UUID.Random () + "/";
capURLs ["MapLayer"] = MainServer.Instance.ServerURI + m_uri;
capURLs ["MapLayerGod"] = MainServer.Instance.ServerURI + m_uri;
MainServer.Instance.AddStreamHandler (new GenericStreamHandler ("POST", m_uri, method));
}
示例8: Close
public void Close(IScene scene)
{
//Deregister the interface
scene.UnregisterModuleInterface<IGridRegisterModule>(this);
m_scene = null;
MainConsole.Instance.InfoFormat("[RegisterRegionWithGrid]: Deregistering region {0} from the grid...",
scene.RegionInfo.RegionName);
//Deregister from the grid server
GridRegion r = new GridRegion(scene.RegionInfo);
r.IsOnline = false;
string error = "";
if (scene.RegionInfo.HasBeenDeleted || !m_markRegionsAsOffline)
scene.GridService.DeregisterRegion(r);
else if ((error = scene.GridService.UpdateMap(r, false)) != "")
MainConsole.Instance.WarnFormat(
"[RegisterRegionWithGrid]: Deregister from grid failed for region {0}, {1}",
scene.RegionInfo.RegionName, error);
}
示例9: CreateAgent
public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out CreateAgentResponse response)
{
response = null;
if (destination == null)
{
response = new CreateAgentResponse();
response.Reason = "Could not connect to destination";
response.Success = false;
return false;
}
CreateAgentRequest request = new CreateAgentRequest();
request.CircuitData = aCircuit;
request.Destination = destination;
request.TeleportFlags = teleportFlags;
AutoResetEvent resetEvent = new AutoResetEvent(false);
OSDMap result = null;
MainConsole.Instance.DebugFormat("[SimulationServiceConnector]: Sending Create Agent to " + destination.ServerURI);
m_syncMessagePoster.Get(destination.ServerURI, request.ToOSD(), (osdresp) =>
{
result = osdresp;
resetEvent.Set();
});
bool success = resetEvent.WaitOne(10000);
if (!success || result == null)
{
response = new CreateAgentResponse();
response.Reason = "Could not connect to destination";
response.Success = false;
return false;
}
response = new CreateAgentResponse();
response.FromOSD(result);
if (!response.Success)
return false;
return response.Success;
}
示例10: GetExternalCaps
public OSDMap GetExternalCaps (UUID agentID, GridRegion region)
{
if (m_registry == null)
return new OSDMap ();
OSDMap resp = new OSDMap ();
if (m_registry.RequestModuleInterface<IGridServerInfoService> () != null)
{
m_servers = m_registry.RequestModuleInterface<IGridServerInfoService> ().GetGridURIs ("SyncMessageServerURI");
OSDMap req = new OSDMap ();
req ["AgentID"] = agentID;
req ["Region"] = region.ToOSD ();
req ["Method"] = "GetCaps";
List<ManualResetEvent> events = new List<ManualResetEvent> ();
foreach (string uri in m_servers.Where((u)=>(!u.Contains(MainServer.Instance.Port.ToString()))))
{
ManualResetEvent even = new ManualResetEvent (false);
m_syncPoster.Get (uri, req, (r) => {
if (r == null)
return;
foreach (KeyValuePair<string, OSD> kvp in r)
resp.Add (kvp.Key, kvp.Value);
even.Set ();
});
events.Add (even);
}
if (events.Count > 0)
ManualResetEvent.WaitAll (events.ToArray ());
}
foreach (var h in GetHandlers(agentID, region.RegionID))
{
if (m_allowedCapsModules.Contains (h.Name))
h.IncomingCapsRequest (agentID, region, m_registry.RequestModuleInterface<ISimulationBase> (), ref resp);
}
return resp;
}
示例11: 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;
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.PostToServer(SyncMessageHelper.TeleportAgent((int) sp.DrawDistance,
agentCircuit, agent, teleportFlags,
finalDestination, sp.Scene.RegionInfo.RegionID));
}
}
示例12: CrossGroupToNewRegion
/// <summary>
/// Move the given scene object into a new region depending on which region its absolute position has moved
/// into.
/// This method locates the new region handle and offsets the prim position for the new region
/// </summary>
/// <param name="attemptedPosition">the attempted out of region position of the scene object</param>
/// <param name="grp">the scene object that we're crossing</param>
/// <param name="destination"></param>
public bool CrossGroupToNewRegion(ISceneEntity grp, Vector3 attemptedPosition, GridRegion destination)
{
if (grp == null)
return false;
if (grp.IsDeleted)
return false;
if (grp.Scene == null)
return false;
if (grp.RootChild.DIE_AT_EDGE)
{
// We remove the object here
try
{
IBackupModule backup = grp.Scene.RequestModuleInterface<IBackupModule>();
if (backup != null)
return backup.DeleteSceneObjects(new[] {grp}, true, true);
}
catch (Exception)
{
MainConsole.Instance.Warn(
"[DATABASE]: exception when trying to remove the prim that crossed the border.");
}
return false;
}
if (grp.RootChild.RETURN_AT_EDGE)
{
// We remove the object here
try
{
List<ISceneEntity> objects = new List<ISceneEntity> {grp};
ILLClientInventory inventoryModule = grp.Scene.RequestModuleInterface<ILLClientInventory>();
if (inventoryModule != null)
return inventoryModule.ReturnObjects(objects.ToArray(), UUID.Zero);
}
catch (Exception)
{
MainConsole.Instance.Warn(
"[SCENE]: exception when trying to return the prim that crossed the border.");
}
return false;
}
Vector3 oldGroupPosition = grp.RootChild.GroupPosition;
// If we fail to cross the border, then reset the position of the scene object on that border.
if (destination != null && !CrossPrimGroupIntoNewRegion(destination, grp, attemptedPosition))
{
grp.OffsetForNewRegion(oldGroupPosition);
grp.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
return false;
}
return true;
}
示例13: TryFindGridRegionForAgentLogin
protected bool TryFindGridRegionForAgentLogin(List<GridRegion> regions, UserAccount account,
UUID session, UUID secureSession,
uint circuitCode, Vector3 position,
IPEndPoint clientIP, AgentCircuitData aCircuit, List<UUID> friendsToInform,
out string seedCap, out string reason, out GridRegion destination)
{
LoginAgentArgs args = null;
foreach (GridRegion r in regions)
{
if (r == null)
continue;
MainConsole.Instance.DebugFormat("[LoginService]: Attempting to log {0} into {1} at {2}...", account.Name, r.RegionName, r.ServerURI);
args = m_registry.RequestModuleInterface<IAgentProcessing>().
LoginAgent(r, aCircuit, friendsToInform);
if (args.Success)
{
aCircuit = MakeAgent(r, account, session, secureSession, circuitCode, position, clientIP);
destination = r;
reason = args.Reason;
seedCap = args.SeedCap;
return true;
}
m_GridService.SetRegionUnsafe(r.RegionID);
}
if (args != null)
{
seedCap = args.SeedCap;
reason = args.Reason;
}
else
{
seedCap = "";
reason = "";
}
destination = null;
return false;
}
示例14: LaunchAgentAtGrid
protected AgentCircuitData LaunchAgentAtGrid(GridRegion destination, TeleportFlags tpFlags, UserAccount account,
UUID session, UUID secureSession, Vector3 position,
string currentWhere,
IPEndPoint clientIP, List<UUID> friendsToInform, out string where, out string reason,
out string seedCap, out GridRegion dest)
{
where = currentWhere;
reason = string.Empty;
uint circuitCode = 0;
AgentCircuitData aCircuit = null;
dest = destination;
#region Launch Agent
circuitCode = (uint) Util.RandomClass.Next();
aCircuit = MakeAgent(destination, account, session, secureSession, circuitCode, position,
clientIP);
aCircuit.TeleportFlags = (uint) tpFlags;
MainConsole.Instance.DebugFormat("[LoginService]: Attempting to log {0} into {1} at {2}...", account.Name, destination.RegionName, destination.ServerURI);
LoginAgentArgs args = m_registry.RequestModuleInterface<IAgentProcessing>().
LoginAgent(destination, aCircuit, friendsToInform);
aCircuit.CachedUserInfo = args.CircuitData.CachedUserInfo;
aCircuit.RegionUDPPort = args.CircuitData.RegionUDPPort;
reason = args.Reason;
reason = "";
seedCap = args.SeedCap;
bool success = args.Success;
if (!success && m_GridService != null)
{
MainConsole.Instance.DebugFormat("[LoginService]: Failed to log {0} into {1} at {2}...", account.Name, destination.RegionName, destination.ServerURI);
//Remove the landmark flag (landmark is used for ignoring the landing points in the region)
aCircuit.TeleportFlags &= ~(uint) TeleportFlags.ViaLandmark;
m_GridService.SetRegionUnsafe(destination.RegionID);
// Make sure the client knows this isn't where they wanted to land
where = "safe";
// Try the default regions
List<GridRegion> defaultRegions = m_GridService.GetDefaultRegions(account.AllScopeIDs);
if (defaultRegions != null)
{
success = TryFindGridRegionForAgentLogin(defaultRegions, account,
session, secureSession, circuitCode, position,
clientIP, aCircuit, friendsToInform,
out seedCap, out reason, out dest);
}
if (!success)
{
// Try the fallback regions
List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.AllScopeIDs,
destination.RegionLocX,
destination.RegionLocY);
if (fallbacks != null)
{
success = TryFindGridRegionForAgentLogin(fallbacks, account,
session, secureSession, circuitCode,
position,
clientIP, aCircuit, friendsToInform,
out seedCap, out reason, out dest);
}
if (!success)
{
//Try to find any safe region
List<GridRegion> safeRegions = m_GridService.GetSafeRegions(account.AllScopeIDs,
destination.RegionLocX,
destination.RegionLocY);
if (safeRegions != null)
{
success = TryFindGridRegionForAgentLogin(safeRegions, account,
session, secureSession, circuitCode,
position, clientIP, aCircuit, friendsToInform,
out seedCap, out reason, out dest);
if (!success)
reason = "No Region Found";
}
}
}
}
#endregion
if (success)
{
MainConsole.Instance.DebugFormat("[LoginService]: Successfully logged {0} into {1} at {2}...", account.Name, destination.RegionName, destination.ServerURI);
//Set the region to safe since we got there
m_GridService.SetRegionSafe(destination.RegionID);
return aCircuit;
}
return null;
}
示例15: CrossPrimGroupIntoNewRegion
/// <summary>
/// Move the given scene object into a new region
/// </summary>
/// <param name="destination"></param>
/// <param name="grp">Scene Object Group that we're crossing</param>
/// <param name="attemptedPos"></param>
/// <returns>
/// true if the crossing itself was successful, false on failure
/// </returns>
protected bool CrossPrimGroupIntoNewRegion(GridRegion destination, ISceneEntity grp, Vector3 attemptedPos)
{
bool successYN = false;
if (destination != null)
{
if (grp.SitTargetAvatar.Count != 0)
{
foreach (UUID avID in grp.SitTargetAvatar)
{
IScenePresence SP = grp.Scene.GetScenePresence(avID);
SP.Velocity = grp.RootChild.PhysActor.Velocity;
InternalCross(SP, attemptedPos, false, destination);
}
foreach (ISceneChildEntity part in grp.ChildrenEntities())
part.SitTargetAvatar = new List<UUID>();
IBackupModule backup = grp.Scene.RequestModuleInterface<IBackupModule>();
if (backup != null)
return backup.DeleteSceneObjects(new[] {grp}, false, false);
return true; //They do all the work adding the prim in the other region
}
ISceneEntity copiedGroup = grp.Copy(false);
copiedGroup.SetAbsolutePosition(true, attemptedPos);
if (grp.Scene != null)
successYN = grp.Scene.RequestModuleInterface<ISimulationService>()
.CreateObject(destination, copiedGroup);
if (successYN)
{
// We remove the object here
try
{
IBackupModule backup = grp.Scene.RequestModuleInterface<IBackupModule>();
if (backup != null)
return backup.DeleteSceneObjects(new[] {grp}, false, true);
}
catch (Exception e)
{
MainConsole.Instance.ErrorFormat(
"[ENTITY TRANSFER MODULE]: Exception deleting the old object left behind on a border crossing for {0}, {1}",
grp, e);
}
}
else
{
if (!grp.IsDeleted)
{
if (grp.RootChild.PhysActor != null)
{
grp.RootChild.PhysActor.CrossingFailure();
}
}
MainConsole.Instance.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp);
}
}
else
{
MainConsole.Instance.Error(
"[ENTITY TRANSFER MODULE]: destination was unexpectedly null in Scene.CrossPrimGroupIntoNewRegion()");
}
return successYN;
}