Update GameClient.cs 使用异步连接Socket

Update GameClient.cs 使用异步连接Socket
This commit is contained in:
ALEXTANG
2022-07-29 14:19:36 +08:00
parent 5ee55a276e
commit 591e3fd2b5

View File

@@ -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();