/// <summary>
        /// 处理登出逻辑
        /// </summary>
        private void HandleLogoutAccount(long account_idx)
        {
            Player player = UnitManager.Instance.GetPlayerByAccount(account_idx) as Player;

            if (player == null)
            {//如果在加载完角色信息前退出,则不会有unit
                return;
            }

            //告诉fs
            ss2fs.LogoutClient fs_msg = PacketPools.Get(ss2fs.msg.LOGOUT_CLIENT) as ss2fs.LogoutClient;
            fs_msg.char_idx = player.char_idx;
            ServerNetManager.Instance.Send2FS(player.fs_uid, fs_msg);

            //告诉ws
            ss2ws.LogoutClient ws_msg = PacketPools.Get(ss2ws.msg.LOGOUT_CLIENT) as ss2ws.LogoutClient;
            ws_msg.char_idx = player.char_idx;
            ServerNetManager.Instance.Send2WS(ws_msg);

            //告诉gl
            ss2gl.LogoutClient gl_msg = PacketPools.Get(ss2gl.msg.LOGOUT_CLIENT) as ss2gl.LogoutClient;
            gl_msg.char_idx = player.char_idx;
            ServerNetManager.Instance.Send2GL(gl_msg);

            //从场景移除
            BaseScene scene = SceneManager.Instance.GetScene(player.scene_obj_idx);

            if (scene != null)
            {
                scene.RemoveUnit(player);
            }
            //从管理器移除
            UnitManager.Instance.RemoveUnit(player);
        }
Beispiel #2
0
 /// <summary>
 /// 账号登出
 /// </summary>
 private void OnLogoutAccount(PacketBase packet)
 {
     ss2gl.LogoutClient msg = packet as ss2gl.LogoutClient;
     UnitManager.Instance.HandleLogout(msg.char_idx);
     Log.Debug("玩家离开游戏:" + msg.char_idx);
 }