Ejemplo n.º 1
0
        protected virtual int RemovePeerFromGame(PlayerPeer peer, LeaveRequest leaveRequest)
        {
            var actor = Actors.RemoveActorByPeer(peer);

            if (actor == null)
            {
                if (Log.IsWarnEnabled)
                {
                    Log.WarnFormat("RemovePeerFromGame - Actor to remove not found for peer: {0}", peer.ConnectionId);
                }

                return(-1);
            }

            ActorEventCache.RemoveEventCache(actor.ActorNr);

            if (DeleteCacheOnLeave)
            {
                EventCache.RemoveEventsByActor(actor.ActorNr);
            }

            // raise leave event
            PublishLeaveEvent(actor, leaveRequest);

            return(actor.ActorNr);
        }
        public void RemoveCache()
        {
            var eventCache = new EventCacheDictionary();

            string msg;

            Assert.That(eventCache.MergeEvent(1, 1, new Hashtable {
                { 1, 1 }
            }, out msg));

            var eventData = new Hashtable {
                { 1, 2 }
            };

            Assert.That(eventCache.MergeEvent(1, 1, eventData, out msg), Is.True);

            EventCache ec;

            Assert.That(eventCache.TryGetEventCache(1, out ec), Is.True);

            Assert.That(eventCache.RemoveEventCache(1), Is.True);

            Assert.That(eventCache.TryGetEventCache(1, out ec), Is.False);
        }