mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Update
Update
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using GameBase;
|
||||
using TEngine;
|
||||
using TEngine.Core.Network;
|
||||
@@ -54,6 +55,10 @@ namespace GameLogic
|
||||
|
||||
public void Connect(string address, bool reconnect = false)
|
||||
{
|
||||
if (Status == GameClientStatus.StatusConnected || Status == GameClientStatus.StatusLogin || Status == GameClientStatus.StatusEnter)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!reconnect)
|
||||
{
|
||||
// SetWatchReconnect(false);
|
||||
@@ -71,8 +76,11 @@ namespace GameLogic
|
||||
_lastAddress = address;
|
||||
|
||||
Status = reconnect ? GameClientStatus.StatusReconnect : GameClientStatus.StatusInit;
|
||||
|
||||
Scene.CreateSession(address, ProtocolType, OnConnectComplete, OnConnectFail);
|
||||
|
||||
if (Scene.Session == null || Scene.Session.IsDisposed)
|
||||
{
|
||||
Scene.CreateSession(address, ProtocolType, OnConnectComplete, OnConnectFail);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnConnectComplete()
|
||||
@@ -116,5 +124,15 @@ namespace GameLogic
|
||||
}
|
||||
Scene.Session.Send(memoryStream,rpcId,routeTypeOpCode,routeId);
|
||||
}
|
||||
|
||||
public void RegisterMsgHandler(uint protocolCode,Action<IResponse> ctx)
|
||||
{
|
||||
MessageDispatcherSystem.Instance.RegisterMsgHandler(protocolCode,ctx);
|
||||
}
|
||||
|
||||
public void UnRegisterMsgHandler(uint protocolCode,Action<IResponse> ctx)
|
||||
{
|
||||
MessageDispatcherSystem.Instance.UnRegisterMsgHandler(protocolCode,ctx);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
using TEngine.Core.Network;
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
public class NetworkUtils
|
||||
{
|
||||
public static bool CheckError(IResponse response)
|
||||
{
|
||||
bool hasError = false;
|
||||
if (response == null)
|
||||
{
|
||||
var networkError = "NetWork Response Error";
|
||||
hasError = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
hasError = response.ErrorCode != 0;
|
||||
}
|
||||
return hasError;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c373208f2ca4f28b35a28434a3b1103
|
||||
timeCreated: 1689262967
|
Reference in New Issue
Block a user