mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Update GameClient.cs 使用异步连接Socket
Update GameClient.cs 使用异步连接Socket
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user