From 591e3fd2b5f3ff6aa309d15fc56f8f8c209dd11d Mon Sep 17 00:00:00 2001 From: ALEXTANG <574809918@qq.com> Date: Fri, 29 Jul 2022 14:19:36 +0800 Subject: [PATCH] =?UTF-8?q?Update=20GameClient.cs=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=BC=82=E6=AD=A5=E8=BF=9E=E6=8E=A5Socket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update GameClient.cs 使用异步连接Socket --- Assets/TEngine/Runtime/Net/GameClient.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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();