private void RemoveInTransitAvatar(InTransitAvatar transitAvatar) { lock (_inTransitAvatars) { _inTransitAvatars.Remove(transitAvatar.UserId); } }
private async Task DoBeginOutboundTransit(InTransitAvatar transitAvatar) { Exception transitError = null; try { await BeginOutboundTransit(transitAvatar); } catch (Exception e) { var last = _lastError; if (last != null && (last.Item1 != transitAvatar.UserId || e.Message != last.Item2)) { _log.ErrorFormat("[TRANSITCONTROLLER]: Error while sending avatar {0}. {1}", transitAvatar.UserId, e); _lastError = Tuple.Create(transitAvatar.UserId, e.Message); } try { transitAvatar.Rollback(); } catch (Exception er) { _log.ErrorFormat("[TRANSITCONTROLLER]: Error while performing rollback of avatar that failed transit. {0}", er); } transitError = e; } if (transitError != null) { try { await transitAvatar.TriggerOnTransitStageChanged(TransitStage.SendError, transitAvatar.RideOnPrims); } catch (Exception e) { _log.ErrorFormat("[TRANSITCONTROLLER]: Error while triggering TransitStage.SendError. {0}", e); } RemoveInTransitAvatar(transitAvatar); throw new AvatarTransitException(transitError.Message, transitError); } else { try { await transitAvatar.TriggerOnTransitStageChanged(TransitStage.SendCompletedSuccess, transitAvatar.RideOnPrims); } catch (Exception e) { _log.ErrorFormat("[TRANSITCONTROLLER]: Error while triggering TransitStage.SendCompletedSuccess. {0}", e); } RemoveInTransitAvatar(transitAvatar); } }
/// <summary> /// Called by an intransit avatar when its transit stage has changed /// </summary> /// <param name="inTransitAvatar"></param> /// <param name="transitStage"></param> internal async Task TriggerOnTransitStageChanged(InTransitAvatar inTransitAvatar, TransitStage transitStage, IEnumerable <uint> rideOnPrims) { var tscDelegate = this.OnTransitStateChanged; if (tscDelegate != null) { await tscDelegate(inTransitAvatar.ScenePresence, transitStage, rideOnPrims); } }
/// <summary> /// Begins a transit to another region /// </summary> /// <param name="transit"></param> /// <param name="transitAvatar"></param> private Task BeginOutboundTransit(InTransitAvatar transitAvatar) { transitAvatar.ScenePresence = _scene.GetScenePresence(transitAvatar.UserId); if (transitAvatar.ScenePresence == null) { throw new InvalidOperationException(String.Format("Avatar {0} is not in the scene and can not be put in transit", transitAvatar.UserId)); } return(transitAvatar.SetNewState(new SendStates.TransitBeginState(transitAvatar))); }
/// <summary> /// Tries to begin a transit from or to another region /// </summary> /// <param name="transit"></param> /// <returns>Whether or not the transit was started, or one was already in progress</returns> public async Task TryBeginTransit(TransitArguments transit) { InTransitAvatar transitAvatar; lock (_inTransitAvatars) { if (_inTransitAvatars.TryGetValue(transit.UserId, out transitAvatar)) { throw new AvatarTransitException("Avatar is already in transit"); } transitAvatar = new InTransitAvatar(this, transit); _inTransitAvatars.Add(transit.UserId, transitAvatar); } if (transit.Type == TransitType.OutboundTeleport || transit.Type == TransitType.OutboundCrossing) { await DoBeginOutboundTransit(transitAvatar); } }
/// <summary> /// Called by an intransit avatar when its transit stage has changed /// </summary> /// <param name="inTransitAvatar"></param> /// <param name="transitStage"></param> internal async Task TriggerOnTransitStageChanged(InTransitAvatar inTransitAvatar, TransitStage transitStage, IEnumerable<uint> rideOnPrims) { var tscDelegate = this.OnTransitStateChanged; if (tscDelegate != null) { await tscDelegate(inTransitAvatar.ScenePresence, transitStage, rideOnPrims); } }
/// <summary> /// Begins a transit to another region /// </summary> /// <param name="transit"></param> /// <param name="transitAvatar"></param> private Task BeginOutboundTransit(InTransitAvatar transitAvatar) { transitAvatar.ScenePresence = _scene.GetScenePresence(transitAvatar.UserId); if (transitAvatar.ScenePresence == null) { throw new InvalidOperationException(String.Format("Avatar {0} is not in the scene and can not be put in transit", transitAvatar.UserId)); } return transitAvatar.SetNewState(new SendStates.TransitBeginState(transitAvatar)); }