29 using System.Collections.Generic;
31 using System.Reflection;
32 using System.Threading;
36 using OpenSim.Framework;
37 using OpenSim.Framework.Capabilities;
38 using OpenSim.Framework.Client;
39 using OpenSim.Region.Framework.Interfaces;
40 using OpenSim.Region.Framework.Scenes;
41 using OpenSim.Region.PhysicsModules.SharedBase;
42 using OpenSim.Services.Interfaces;
45 namespace OpenSim.
Region.CoreModules.Framework.EntityTransfer
79 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
80 private static readonly
string LogHeader =
"[ENTITY TRANSFER STATE MACHINE]";
86 public bool EnableWaitForAgentArrivedAtDestination {
get; set; }
90 private Dictionary<UUID, AgentTransferState> m_agentsInTransit =
new Dictionary<UUID, AgentTransferState>();
102 internal bool SetInTransit(UUID
id)
104 m_log.DebugFormat(
"{0} SetInTransit. agent={1}, newState=Preparing", LogHeader, id);
105 lock (m_agentsInTransit)
107 if (!m_agentsInTransit.ContainsKey(
id))
109 m_agentsInTransit[id] = AgentTransferState.Preparing;
126 m_log.DebugFormat(
"{0} UpdateInTransit. agent={1}, newState={2}", LogHeader, id, newState);
128 bool transitionOkay =
false;
131 bool failIfNotOkay =
true;
134 string failureMessage = null;
138 lock (m_agentsInTransit)
141 if (!m_agentsInTransit.ContainsKey(
id))
144 failureMessage = string.Format(
145 "Agent with ID {0} is not registered as in transit in {1}",
146 id, m_mod.Scene.RegionInfo.RegionName);
148 failIfNotOkay =
false;
152 oldState = m_agentsInTransit[id];
156 transitionOkay =
true;
160 transitionOkay =
true;
164 transitionOkay =
true;
168 transitionOkay =
true;
175 transitionOkay =
true;
179 failIfNotOkay =
false;
186 "Agent with ID {0} is not allowed to move from old transit state {1} to new state {2} in {3}",
187 id, oldState, newState, m_mod.Scene.RegionInfo.RegionName);
192 m_agentsInTransit[id] = newState;
198 else if (failIfNotOkay)
200 m_log.DebugFormat(
"{0} UpdateInTransit. Throwing transition failure = {1}", LogHeader, failureMessage);
201 throw new Exception(failureMessage);
216 return transitionOkay;
228 lock (m_agentsInTransit)
230 if (!m_agentsInTransit.ContainsKey(
id))
233 return m_agentsInTransit[id];
242 internal bool ResetFromTransit(UUID
id)
244 lock (m_agentsInTransit)
246 if (m_agentsInTransit.ContainsKey(
id))
255 "[ENTITY TRANSFER STATE MACHINE]: Agent with ID {0} should not exit directly from state {1}, should go to {2} state first in {3}",
256 id, state, AgentTransferState.CleaningUp, m_mod.Scene.RegionInfo.RegionName);
263 m_agentsInTransit.Remove(id);
266 "[ENTITY TRANSFER STATE MACHINE]: Agent {0} cleared from transit in {1}",
267 id, m_mod.Scene.RegionInfo.RegionName);
274 "[ENTITY TRANSFER STATE MACHINE]: Agent {0} requested to clear from transit in {1} but was already cleared",
275 id, m_mod.Scene.RegionInfo.RegionName);
280 internal bool WaitForAgentArrivedAtDestination(UUID
id)
282 if (!m_mod.WaitForAgentArrivedAtDestination)
285 lock (m_agentsInTransit)
289 if (currentState == null)
292 "Asked to wait for destination callback for agent with ID {0} in {1} but agent is not in transit",
293 id, m_mod.Scene.RegionInfo.RegionName));
298 "Asked to wait for destination callback for agent with ID {0} in {1} but agent is in state {2}",
299 id, m_mod.Scene.RegionInfo.RegionName, currentState));
309 lock (m_agentsInTransit)
322 internal void SetAgentArrivedAtDestination(UUID
id)
324 lock (m_agentsInTransit)
326 if (!m_agentsInTransit.ContainsKey(
id))
329 "[ENTITY TRANSFER STATE MACHINE]: Region {0} received notification of arrival in destination of agent {1} but no teleport request is active",
330 m_mod.Scene.RegionInfo.RegionName, id);
341 "[ENTITY TRANSFER STATE MACHINE]: Region {0} received notification of arrival in destination of agent {1} but notification has already previously been received",
342 m_mod.Scene.RegionInfo.RegionName, id);
347 "[ENTITY TRANSFER STATE MACHINE]: Region {0} received notification of arrival in destination of agent {1} but agent is in state {2}",
348 m_mod.Scene.RegionInfo.RegionName, id, currentState);
353 m_agentsInTransit[id] = AgentTransferState.ReceivedAtDestination;
OpenSim.Services.Interfaces.GridRegion GridRegion
EntityTransferStateMachine(EntityTransferModule module)
AgentTransferState
The possible states that an agent can be in when its being transferred between regions.
Records the state of entities when they are in transfer within or between regions (cross or teleport)...