Add close connection

main
Kevin Li 2023-08-30 16:49:30 +08:00
parent 466933babe
commit b6ca4d3f1e
3 changed files with 9 additions and 2 deletions

View File

@ -772,7 +772,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1000, y: 100}
m_SizeDelta: {x: 1000, y: 200}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &549377895
GameObject:

View File

@ -49,6 +49,8 @@ public class GameClient : MonoBehaviour
{
_kcpDofClient.OnConnected -= OnConnected;
_kcpDofClient.OnServerMessage -= OnServerMessage;
_kcpDofClient.Close();
}
IEnumerator _DelayCall(float delay_secs, Action callback)
@ -187,7 +189,7 @@ public class GameClient : MonoBehaviour
{
if (msg.PlayerEntered != null)
{
infoText.text = $"Player Enter cid: {msg.PlayerEntered.Cid}, Waiting for player";
infoText.text = $"{nickName} Enter cid: {msg.PlayerEntered.Cid}, Waiting for other player";
goes[1].SetActive(false);
}
else if (msg.GameStart != null)

View File

@ -63,6 +63,11 @@ public class KcpDofClient : KcpListener
dataBuf.Release();
}
public void Close()
{
_kcpClient.stop();
}
public void onConnected(Ukcp ukcp)
{
Debug.Log($"[KcpDofClient]onConnected");