diff --git a/Assets/TEngine/Runtime/Net/GameClient.cs b/Assets/TEngine/Runtime/Net/GameClient.cs index cde28037..96286c58 100644 --- a/Assets/TEngine/Runtime/Net/GameClient.cs +++ b/Assets/TEngine/Runtime/Net/GameClient.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using TEngineProto; using UnityEngine; @@ -108,6 +109,21 @@ namespace TEngine.Net m_connect = null; } + public async void ConnectAsync(string host, int port, bool reconnect = false) + { + try + { + await Task.Run((() => + { + Connect(host, port, reconnect); + })); + } + catch (Exception e) + { + TLogger.LogException(e.Message); + } + } + public bool Connect(string host, int port, bool reconnect = false) { ResetParam();