diff --git a/ClientCore/Network/NetworkHelper.cs b/ClientCore/Network/NetworkHelper.cs
index eccd59d..f21471b 100644
--- a/ClientCore/Network/NetworkHelper.cs
+++ b/ClientCore/Network/NetworkHelper.cs
@@ -20,12 +20,12 @@ namespace ClientCore.Network
public NetworkHelper(ServerType serverType,long UID = -1)
{
//指定接收服务器数据事件
- OnDataCallBack += GetDataCallBack;
+ OnReceiveData += GetDataCallBack;
//断开连接
OnClose += OnConnectClose;
//网络库调试信息输出事件,用于打印连接断开,收发事件
- OnLogOut += NetworkDeBugLog;
OnConnected += NetworkConnected;
+ OnLogOut += NetworkDeBugLog;
mServerType = serverType;
mUID = UID;
}
diff --git a/NetLib/HaoYueNet.ClientNetwork.dll b/NetLib/HaoYueNet.ClientNetwork.dll
index a8d7072..481893a 100644
Binary files a/NetLib/HaoYueNet.ClientNetwork.dll and b/NetLib/HaoYueNet.ClientNetwork.dll differ
diff --git a/NetLib/HaoYueNet.ServerNetwork.dll b/NetLib/HaoYueNet.ServerNetwork.dll
index 1f7ca2a..b702b4b 100644
Binary files a/NetLib/HaoYueNet.ServerNetwork.dll and b/NetLib/HaoYueNet.ServerNetwork.dll differ
diff --git a/ServerCore/NetWork/IOCPNetWork.cs b/ServerCore/NetWork/IOCPNetWork.cs
index 10068a8..b71e229 100644
--- a/ServerCore/NetWork/IOCPNetWork.cs
+++ b/ServerCore/NetWork/IOCPNetWork.cs
@@ -1,24 +1,25 @@
-using AxibugProtobuf;
-using HaoYueNet.ServerNetwork;
+using HaoYueNet.ServerNetwork;
using ServerCore.Common.Enum;
using ServerCore.Event;
using ServerCore.Manager;
using System.Net;
-using System.Net.Sockets;
namespace ServerCore.NetWork
{
- public class IOCPNetWork : SocketManager
+ public class IOCPNetWork : TcpSaeaServer
{
ServerType mServerType;
public IOCPNetWork(int numConnections, int receiveBufferSize, ServerType serverType)
: base(numConnections, receiveBufferSize)
{
mServerType = serverType;
- ClientNumberChange += IOCPNetWork_ClientNumberChange;
+ OnClientNumberChange += ClientNumberChange;
+ OnReceive += ReceiveData;
+ OnDisconnected += OnDisconnect;
+ OnNetLog += OnShowNetLog;
}
- private void IOCPNetWork_ClientNumberChange(int num, AsyncUserToken token)
+ void ClientNumberChange(int num, AsyncUserToken token)
{
Console.WriteLine("Client数发生变化");
}
@@ -29,7 +30,7 @@ namespace ServerCore.NetWork
/// 协议ID
/// 错误编号
/// 业务数据
- public override void DataCallBack(AsyncUserToken token, int CMDID, byte[] data)
+ void ReceiveData(AsyncUserToken token, int CMDID, byte[] data)
{
//DataCallBackToOld(token.Socket, CMDID, data);
ServerManager.g_Log.Debug("收到消息 CMDID =>" + CMDID + " 数据长度=>" + data.Length);
@@ -37,30 +38,22 @@ namespace ServerCore.NetWork
NetMsg.Instance.PostNetMsgEvent(CMDID, token.Socket, data);
}
- //public void DataCallBackToOld(Socket sk, int CMDID, byte[] data)
- //{
- // ServerManager.g_Log.Debug("收到消息 CMDID =>" + CMDID + " 数据长度=>" + data.Length);
- // try
- // {
- // //抛出网络数据
- // NetMsg.Instance.PostNetMsgEvent(CMDID, sk, data);
- // }
- // catch (Exception ex)
- // {
- // Console.WriteLine("逻辑处理错误:" + ex.ToString());
- // }
- //}
-
///
/// 断开连接
///
///
- public override void OnClose(AsyncUserToken token)
+ void OnDisconnect(AsyncUserToken token)
{
ServerManager.g_Log.Debug($"断开连接,ServerType->{mServerType} | {((IPEndPoint)token.Socket.LocalEndPoint).Address}");
//ServerManager.g_ClientMgr.SetClientOfflineForSocket(token.Socket);
- //TODO 要删除不同的
+ //要删除不同的
EventSystem.Instance.PostEvent(EEvent.OnSocketDisconnect, mServerType, token.Socket);
}
+
+
+ void OnShowNetLog(string msg)
+ {
+ ServerManager.g_Log.Debug(msg);
+ }
}
}