/// <summary> /// 断开与战斗服的连接 /// </summary> public void DisConnectFightServer() { Player player = UnitManager.Instance.GetPlayerByIdx(m_char_idx); if (player == null) { return; } if (player.fs_uid > 0 && m_connect_state == eFSConnectState.Connected) { //告诉fs ss2fs.LogoutClient fs_msg = PacketPools.Get(ss2fs.msg.LOGOUT_CLIENT) as ss2fs.LogoutClient; fs_msg.char_idx = m_char_idx; ServerNetManager.Instance.Send2FS(player.fs_uid, fs_msg); //告诉gs分配给玩家的fs ss2gs.NotifyServer gs_msg = PacketPools.Get(ss2gs.msg.NOTIFY_SERVER) as ss2gs.NotifyServer; gs_msg.account_idx = player.account_idx; gs_msg.s_type = eServerType.FIGHT; gs_msg.fs_uid = 0; ServerNetManager.Instance.Send(player.client_uid.srv_uid, gs_msg); m_connect_state = eFSConnectState.UnConnect; } }
/// <summary> /// 通知网关玩家连接的服务器 /// </summary> private void OnNotifyServer(PacketBase packet) { ss2gs.NotifyServer msg = packet as ss2gs.NotifyServer; ClientSession session = ClientSessionManager.Instance.GetSessionByAccount(msg.account_idx); if (session != null) { switch (msg.s_type) { case eServerType.FIGHT: session.fs_uid = msg.fs_uid; break; } } }
/// <summary> /// 连接战斗服:战斗服只在需要的时候连接,如匹配,战斗中等 /// </summary> public void ConnectFightServer() { //已经连接了战斗服,直接返回 if (m_connect_state == eFSConnectState.Connected) { return; } Player player = UnitManager.Instance.GetPlayerByIdx(m_char_idx); if (player == null || player.fs_uid == 0) { return; } //判断是否已经有战斗服 ConnAppProc app_server = ServerNetManager.Instance.GetConnApp(player.fs_uid); if (app_server == null || app_server.srv_info.srv_status != eConnAppStatus.CONNECTED) { return; } //如果存在,就当已经连上,因为本身ss已经连上fs { //告诉fs ss2fs.LoginClient msg = PacketPools.Get(ss2fs.msg.LOGIN_CLIENT) as ss2fs.LoginClient; msg.client_uid = player.client_uid; msg.data.Copy(player.unit_attr.player_info); ServerNetManager.Instance.Send2FS(player.fs_uid, msg); //告诉gs分配给玩家的fs ss2gs.NotifyServer gs_msg = PacketPools.Get(ss2gs.msg.NOTIFY_SERVER) as ss2gs.NotifyServer; gs_msg.account_idx = player.account_idx; gs_msg.s_type = eServerType.FIGHT; gs_msg.fs_uid = player.fs_uid; ServerNetManager.Instance.Send(player.client_uid.srv_uid, gs_msg); m_connect_state = eFSConnectState.Connected; } }