匹配自动重连
- 修复第一次连接时ClientID为0导致匹配失败的问题 - 在GameClientMatchmaker中添加ClientID检测和自动重连逻辑 - 当检测到ClientID为0时,等待0.5秒后自动断开并重新连接 - 优化MatchmakingPanel显示逻辑,根据ClientID状态显示正确的连接状态
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TcgEngine.Client;
|
||||
using TcgEngine;
|
||||
@@ -34,18 +35,24 @@ namespace TcgEngine.UI
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (GameClientMatchmaker.Get().IsConnected())
|
||||
text.text = "Finding Opponent...";
|
||||
GameClientMatchmaker matchmaker = GameClientMatchmaker.Get();
|
||||
bool is_connected = matchmaker.IsConnected();
|
||||
ulong client_id = TcgNetwork.Get().ClientID;
|
||||
|
||||
// 显示连接状态
|
||||
if (is_connected && client_id != 0)
|
||||
text.text = "正在寻找对手...";
|
||||
else
|
||||
text.text = "Connecting to server...";
|
||||
text.text = "正在连接到服务器...";
|
||||
|
||||
code_txt.text = "";
|
||||
|
||||
string group = GameClientMatchmaker.Get().GetGroup();
|
||||
string group = matchmaker.GetGroup();
|
||||
if (group != null && group.StartsWith("code_"))
|
||||
code_txt.text = group.Replace("code_", "");
|
||||
}
|
||||
|
||||
|
||||
public void SetCount(int players)
|
||||
{
|
||||
if (players_txt != null)
|
||||
|
||||
Reference in New Issue
Block a user