Esempio n. 1
0
        public void PublishEventDiconnected(Actor actor, int? newMasterClientId)
        {
            if (this.SuppressRoomEvents)
            {
                return;
            }

            if (this.ActorsManager.ActorsCount > 0 && actor != null)
            {
                // instead of ev disconnect we discussed a prop. change
                // decided for ev because for clients its an important state change
                // and they would have to filter property changes ...

                //var propertiesChangedEvent = new PropertiesChangedEvent(0)
                //{
                //    TargetActorNumber = actor.ActorNr,
                //    Properties = new Hashtable()
                //    {
                //        {(byte)ActorParameter.IsInactive, true}
                //    }
                //};

                var disconnectEvent = new LeaveEvent(actor.ActorNr, isInactive: true)
                {
                    MasterClientId = newMasterClientId
                };

                this.PublishEvent(disconnectEvent, this.Actors, new SendParameters());
            }
        }
Esempio n. 2
0
        /// <summary>
        ///   Sends a <see cref = "LeaveEvent" /> to all <see cref = "Actor" />s.
        /// </summary>
        /// <param name = "actor">
        ///   The actor which sents the event.
        /// </param>
        /// <param name="newMasterClientId"></param>
        protected virtual void PublishLeaveEvent(Actor actor, int? newMasterClientId)
        {
            if (this.SuppressRoomEvents)
            {
                return;
            }

            if (this.ActorsManager.ActorsCount > 0 && actor != null)
            {
                var actorNumbers = this.ActorsManager.ActorsGetActorNumbers();
                var leaveEvent = new LeaveEvent(actor.ActorNr, actorNumbers.ToArray())
                {
                    MasterClientId = newMasterClientId
                };

                if (actor.Peer == null || actor.Peer.JoinStage >= HivePeer.JoinStages.EventsPublished)
                {
                    this.PublishEvent(leaveEvent, this.Actors, new SendParameters());
                }
            }
        }