Example #1
0
        /// <summary>
        /// Called by the transit manager when this avatar has entered a new transit stage
        /// </summary>
        /// <param name="stage"></param>
        public async Task TransitStateChange(AvatarTransit.TransitStage stage, IEnumerable <uint> rideOnPrimIds)
        {
            if (stage == AvatarTransit.TransitStage.SendBegin)
            {
                Physics.Manager.PhysicsActor pa = ScenePresence.PhysicsActor;

                if (pa != null)
                {
                    ScenePresence.PhysicsActor.Suspend();
                }

                if (_capsControl != null)
                {
                    _capsControl.PauseTraffic();
                }
                await _udpCircuit.PauseUpdatesAndFlush();
            }
            else if (stage == AvatarTransit.TransitStage.SendCompletedSuccess || stage == AvatarTransit.TransitStage.SendError)
            {
                if (_capsControl != null)
                {
                    _capsControl.ResumeTraffic();
                }
                if (stage == AvatarTransit.TransitStage.SendCompletedSuccess)
                {
                    _udpCircuit.ResumeUpdates(rideOnPrimIds);
                }
                else
                {
                    _udpCircuit.ResumeUpdates(null);    // don't kill object update if not leaving region
                }
                if (stage == AvatarTransit.TransitStage.SendError)
                {
                    Physics.Manager.PhysicsActor pa = ScenePresence.PhysicsActor;

                    if (pa != null)
                    {
                        pa.Resume(false, null);
                    }
                }
            }
        }
        private async Task _transitController_OnTransitStateChanged(Scenes.ScenePresence sp, AvatarTransit.TransitStage newStage,
                                                                    IEnumerable <uint> rideOnPrims)
        {
            AvatarConnection conn;

            lock (_connectionsByUserId)
            {
                _connectionsByUserId.TryGetValue(sp.UUID, out conn);
            }

            if (conn != null)
            {
                await conn.TransitStateChange(newStage, rideOnPrims);
            }
            else
            {
                throw new InvalidOperationException("OnTransitStateChanged called for unknown connection");
            }
        }