Ejemplo n.º 1
0
        /// <summary>
        /// Recover session
        /// </summary>
        /// <param name="session"></param>
        /// <param name="newSessionKey"></param>
        /// <param name="socket"></param>
        /// <param name="appServer"></param>
        /// <returns></returns>
        public static void Recover(GameSession session, Guid newSessionKey, ExSocket socket, ISocket appServer)
        {
            var newSession = Get(newSessionKey);

            if (session != null &&
                newSession != null &&
                session != newSession)
            {
                try
                {
                    session._exSocket.Close();
                }
                catch
                {
                }
                //modify socket's keycod not found reason
                socket.Reset(session.KeyCode);
                session.InitSocket(socket, appServer);

                GameSession temp;
                if (_globalSession.TryRemove(newSessionKey, out temp))
                {
                    OnChangedSave();
                }
                //
                if (OnRecover != null)
                {
                    OnRecover(session, null);
                }
            }
        }