예제 #1
0
 /// <summary>
 /// Transfers a(n) <see cref="ISession"/> to another world
 /// </summary>
 void IWorldServer.TransferSession(int sessionId, int zoneId)
 {
     this.messageFiber.Enqueue(() =>
     {
         ISession session;
         if (sessions.TryGetValue(sessionId, out session))
         {
             sessions.Remove(sessionId);
             // destroy the session due to disconnect
             session.Destroy(DestroySessionReason.Transfer);
             // notifying the master to update the state so the client can start sending messages
             this.SendOperationRequest(
                 new OperationRequest((byte)ServerOperationCode.TransferSession,
                                      new TransferSession
             {
                 SessionId = session.SessionId,
                 WorldId   = zoneId,
             }),
                 new SendParameters());
         }
         else
         {
             Logger.ErrorFormat("[TransferSession]: Session (Id={0}) cannot be found", sessionId);
         }
     });
 }
예제 #2
0
        /// <summary>
        /// Removes a(n) <see cref="IWorld"/> from the social
        /// </summary>
        public bool RemoveWorld(short worldId)
        {
            // using a while loop for the lock-timeout
            while (!worlds.Remove(worldId))
            {
                IWorld existingWorld;
                if (!worlds.TryGetValue(worldId, out existingWorld))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #3
0
        /// <summary>
        /// Removes a(n) <see cref="Channel"/>.
        /// </summary>
        /// <returns> Returns true if successful </returns>
        public bool RemoveChannel(Channel channel)
        {
            Channel theChannel;

            if (channels.TryGetValue(channel.Id, out theChannel))
            {
                if (theChannel == channel)
                {
                    channels.Remove(theChannel.Id);
                    theChannel.Dispose();
                    return(true);
                }
            }
            return(false);
        }
예제 #4
0
        /// <summary>
        /// Removes a(n) <see cref="ISession"/>.
        /// </summary>
        /// <param name="removeSession"> </param>
        private void HandleRemoveSession(RemoveSession removeSession)
        {
            ISession session;

            if (sessions.TryGetValue(removeSession.SessionId, out session))
            {
                sessions.Remove(removeSession.SessionId);
                // destroy the session due to disconnect
                session.Destroy(DestroySessionReason.Disconnect);
            }
            else
            {
                Logger.ErrorFormat("[HandleRemoveSession]: Session (Id={0}) cannot be found", removeSession.SessionId);
            }
        }
예제 #5
0
        /// <summary>
        /// Removes a(n) <see cref="MmoZone"/>.
        /// </summary>
        public bool RemoveZone(MmoZone zone)
        {
            MmoZone theZone;

            if (zones.TryGetValue(zone.Id, out theZone))
            {
                // TODO: Recalculate bounds
                // TODO: Disconnect every player from that zone
                if (theZone == zone)
                {
                    zones.Remove(zone.Id);
                    theZone.Dispose();
                    return(true);
                }
            }
            return(false);
        }
예제 #6
0
 /// <summary>
 /// Removes an item from the cache
 /// </summary>
 public bool RemoveItem(MmoGuid guid)
 {
     return(objects.Remove(guid.Type, guid.Id));
 }