完善网络框架,增加服务器断开连接回调

This commit is contained in:
ALEXTANG
2023-07-18 17:36:48 +08:00
parent a473971cfb
commit 526baf45fa
39 changed files with 559 additions and 308 deletions

View File

@@ -67,12 +67,12 @@ namespace TEngine
Scenes.Add(scene);
return scene;
}
public void CreateSession(string remoteAddress, NetworkProtocolType networkProtocolType, Action onConnectComplete, Action onConnectFail, int connectTimeout = 5000)
public void CreateSession(string remoteAddress, NetworkProtocolType networkProtocolType, Action onConnectComplete, Action onConnectFail,Action onConnectDisconnect, int connectTimeout = 5000)
{
var address = NetworkHelper.ToIPEndPoint(remoteAddress);
var clientNetworkComponent = GetComponent<ClientNetworkComponent>() ?? AddComponent<ClientNetworkComponent>();
clientNetworkComponent.Initialize(networkProtocolType, NetworkTarget.Outer);
clientNetworkComponent.Connect(address, onConnectComplete, onConnectFail, connectTimeout);
clientNetworkComponent.Connect(address, onConnectComplete, onConnectFail,onConnectDisconnect, connectTimeout);
Session = clientNetworkComponent.Session;
}
#else