Example #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);
         }
     });
 }
Example #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);
        }
Example #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);
        }
Example #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);
            }
        }
Example #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);
        }
Example #6
0
 /// <summary>
 /// Removes an item from the cache
 /// </summary>
 public bool RemoveItem(MmoGuid guid)
 {
     return(objects.Remove(guid.Type, guid.Id));
 }