dev-tcptunnel #1
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,12 +1,14 @@
|
||||
using ClientCore;
|
||||
using ClientCore.Data;
|
||||
using ClientCore.Event;
|
||||
|
||||
App.Init("127.0.0.1", 23846);
|
||||
App.Init("127.0.0.1", 23846, 23847);
|
||||
|
||||
//注册事件
|
||||
EventSystem.Instance.RegisterEvent(EEvent.UserLogin, OnUserLogin);
|
||||
EventSystem.Instance.RegisterEvent(EEvent.TcpTunnelHelloResp, OnTcpTunnelHelloResp);
|
||||
EventSystem.Instance.RegisterEvent<long>(EEvent.UserJoin, OnUserJoin);
|
||||
EventSystem.Instance.RegisterEvent<long>(EEvent.UserLeave, OnUserLeave);
|
||||
|
||||
EventSystem.Instance.RegisterEvent<string, string>(EEvent.OnChatMsg, OnChatMsg);
|
||||
|
||||
while (true)
|
||||
@ -17,6 +19,15 @@ while (true)
|
||||
string[] CmdArr = CommandStr.Split(' ');
|
||||
switch (Command)
|
||||
{
|
||||
case "info":
|
||||
{
|
||||
Console.WriteLine($"IsLogin:{App.userMgr.bLogin}");
|
||||
if (App.userMgr.bLogin)
|
||||
{
|
||||
Console.WriteLine($"UID:{App.userMgr.MainPlayer.UID} NickName:{App.userMgr.MainPlayer.NickName}");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "login":
|
||||
case "l":
|
||||
if (CmdArr.Length < 2)
|
||||
@ -26,6 +37,18 @@ while (true)
|
||||
}
|
||||
App.login.Login(CmdArr[1]);
|
||||
break;
|
||||
case "tcphey":
|
||||
case "they":
|
||||
App.p2ptcp.SendHellToSev();
|
||||
break;
|
||||
case "tu":
|
||||
if (CmdArr.Length < 2)
|
||||
{
|
||||
Console.WriteLine("缺省用户名");
|
||||
return;
|
||||
}
|
||||
App.p2ptcp.SendDoTunnel(Convert.ToInt64(CmdArr[1]));
|
||||
break;
|
||||
case "say":
|
||||
if (CmdArr.Length < 2)
|
||||
{
|
||||
@ -34,22 +57,46 @@ while (true)
|
||||
}
|
||||
App.chat.SendChatMsg(CmdArr[1]);
|
||||
break;
|
||||
case "ulist":
|
||||
{
|
||||
UserInfo[] ulist = App.userMgr.GetUserInfo();
|
||||
Console.WriteLine("User总数"+ ulist.Length);
|
||||
for (int i = 0; i < ulist.Length; i++)
|
||||
{
|
||||
Console.WriteLine($"[{i}] UID->{ulist[i].UID} | NickName->{ulist[i].NickName} | State->{ulist[i].State}");
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("未知命令" + CommandStr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void OnChatMsg(string str1, string str2)
|
||||
void OnUserLogin()
|
||||
{
|
||||
Console.WriteLine($"[Chat]{str1}:{str2}");
|
||||
Console.WriteLine($"[User]登录成功");
|
||||
App.userMgr.Send_GetUserList();
|
||||
|
||||
App.clientMgr.ConnectTcpTunnelServer();
|
||||
}
|
||||
|
||||
void OnTcpTunnelHelloResp()
|
||||
{
|
||||
Console.WriteLine($"[TcpTunnel]TcpTunnelHelloResp");
|
||||
}
|
||||
|
||||
void OnUserJoin(long UID)
|
||||
{
|
||||
Console.WriteLine($"[User]用户{UID}上线");
|
||||
}
|
||||
|
||||
void OnUserLeave(long UID)
|
||||
{
|
||||
Console.WriteLine($"[User]用户{UID}下线");
|
||||
}
|
||||
}
|
||||
|
||||
void OnChatMsg(string str1, string str2)
|
||||
{
|
||||
Console.WriteLine($"[Chat]{str1}:{str2}");
|
||||
}
|
||||
|
@ -15,19 +15,27 @@ namespace ClientCore
|
||||
public static string IP;
|
||||
public static int Port;
|
||||
public static LogManager log;
|
||||
public static NetworkHelper networkHelper;
|
||||
public static ClientManager clientMgr;
|
||||
public static P2PTcp p2ptcp;
|
||||
public static NetworkHelper networkMain;
|
||||
public static NetworkHelper networkTcp2S;
|
||||
public static AppLogin login;
|
||||
public static AppChat chat;
|
||||
public static UserMgr userMgr;
|
||||
|
||||
public static void Init(string IP, int port)
|
||||
public static void Init(string IP, int port, int tcptunnelport)
|
||||
{
|
||||
log = new LogManager();
|
||||
networkHelper = new NetworkHelper();
|
||||
login = new AppLogin();
|
||||
chat = new AppChat();
|
||||
userMgr = new UserMgr();
|
||||
networkHelper.Init(IP, port);
|
||||
clientMgr = new ClientManager();
|
||||
clientMgr.SetIpData(IP, port, tcptunnelport);
|
||||
p2ptcp = new P2PTcp();
|
||||
networkMain = new NetworkHelper(Enum.ServerType.MainServer);
|
||||
networkMain.Init(IP, port);
|
||||
//networkTcp2S = new NetworkHelper(Enum.ServerType.TcpTunnelServer);
|
||||
//networkTcp2S.Init(IP, tcptunnelport);
|
||||
}
|
||||
}
|
||||
|
||||
|
15
ClientCore/Data/UserData.cs
Normal file
15
ClientCore/Data/UserData.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClientCore.Data
|
||||
{
|
||||
public class UserInfo
|
||||
{
|
||||
public long UID;//用户ID
|
||||
public string NickName;//昵称
|
||||
public int State;//状态
|
||||
}
|
||||
}
|
16
ClientCore/Enum/CommEnum.cs
Normal file
16
ClientCore/Enum/CommEnum.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClientCore.Enum
|
||||
{
|
||||
public enum ServerType
|
||||
{
|
||||
MainServer,
|
||||
TcpTunnelServer,
|
||||
|
||||
TcpP2PTarget
|
||||
}
|
||||
}
|
@ -9,8 +9,16 @@ namespace ClientCore.Event
|
||||
public enum EEvent
|
||||
{
|
||||
// 添加你自己需要的事件类型
|
||||
UserLogin,
|
||||
UserJoin,
|
||||
UserLeave,
|
||||
OnChatMsg,
|
||||
|
||||
//打洞流程
|
||||
TcpTunnelHelloResp,
|
||||
|
||||
//连接管理
|
||||
OnSocketConnect,
|
||||
OnSocketDisconnect,
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace ClientCore.Manager
|
||||
{
|
||||
ChatMsg = ChatMsg,
|
||||
};
|
||||
App.networkHelper.SendToServer((int)CommandID.CmdChatmsg, ProtoBufHelper.Serizlize(msg));
|
||||
App.networkMain.SendToServer((int)CommandID.CmdChatmsg, ProtoBufHelper.Serizlize(msg));
|
||||
}
|
||||
|
||||
public void RecvChatMsg(byte[] reqData)
|
||||
|
@ -1,10 +1,17 @@
|
||||
using AxibugProtobuf;
|
||||
using ClientCore.Common;
|
||||
using ClientCore.Event;
|
||||
using ClientCore.Network;
|
||||
|
||||
namespace ClientCore.Manager
|
||||
{
|
||||
public class AppLogin
|
||||
{
|
||||
public AppLogin()
|
||||
{
|
||||
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdLogin, RecvCmdLogin);
|
||||
}
|
||||
|
||||
public void Login(string Account)
|
||||
{
|
||||
Protobuf_Login msg = new Protobuf_Login()
|
||||
@ -12,7 +19,14 @@ namespace ClientCore.Manager
|
||||
LoginType = 0,
|
||||
Account = Account,
|
||||
};
|
||||
App.networkHelper.SendToServer((int)CommandID.CmdLogin, ProtoBufHelper.Serizlize(msg));
|
||||
App.networkMain.SendToServer((int)CommandID.CmdLogin, ProtoBufHelper.Serizlize(msg));
|
||||
}
|
||||
|
||||
public void RecvCmdLogin(byte[] reqData)
|
||||
{
|
||||
Protobuf_Login_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Login_RESP>(reqData);
|
||||
App.userMgr.SetMainPlayer(msg.UID, msg.NickName, 0);
|
||||
EventSystem.Instance.PostEvent(EEvent.UserLogin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
208
ClientCore/Manager/ClientManager.cs
Normal file
208
ClientCore/Manager/ClientManager.cs
Normal file
@ -0,0 +1,208 @@
|
||||
using AxibugProtobuf;
|
||||
using ClientCore.Common;
|
||||
using ClientCore.Enum;
|
||||
using ClientCore.Event;
|
||||
using ClientCore.Network;
|
||||
using System.Net.Sockets;
|
||||
using System.Timers;
|
||||
|
||||
namespace ClientCore.Manager
|
||||
{
|
||||
public class ClientManager
|
||||
{
|
||||
bool bTryReConTcpTunnelServer = false;
|
||||
string IP;
|
||||
int port;
|
||||
int tcptunnelport;
|
||||
int LastlocalPort = 0;
|
||||
|
||||
Dictionary<long,NetworkHelper> DictUID2TcpTaret = new Dictionary<long,NetworkHelper>();
|
||||
|
||||
public ClientManager()
|
||||
{
|
||||
//注册事件
|
||||
EventSystem.Instance.RegisterEvent<ServerType, bool>(EEvent.OnSocketConnect, OnSocketConnect);
|
||||
EventSystem.Instance.RegisterEvent<ServerType, long>(EEvent.OnSocketDisconnect, OnSocketDisconnect);
|
||||
}
|
||||
|
||||
public void SetIpData(string IP, int port, int tcptunnelport)
|
||||
{
|
||||
this.IP = IP;
|
||||
this.port = port;
|
||||
this.tcptunnelport = tcptunnelport;
|
||||
}
|
||||
|
||||
void OnSocketConnect(ServerType servertype, bool IsOk)
|
||||
{
|
||||
switch (servertype)
|
||||
{
|
||||
case ServerType.MainServer:
|
||||
{
|
||||
if (IsOk)
|
||||
{
|
||||
Console.WriteLine("MainServer连接成功");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("MainServer连接失败");
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ServerType.TcpTunnelServer:
|
||||
{
|
||||
bTryReConTcpTunnelServer = false;
|
||||
if (IsOk)
|
||||
{
|
||||
Console.WriteLine("TcpTunnelServer连接成功");
|
||||
App.p2ptcp.SendHellToSev();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("TcpTunnelServer连接失败");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ServerType.TcpP2PTarget:
|
||||
{
|
||||
if (IsOk)
|
||||
{
|
||||
Console.WriteLine("TcpP2PTarget连接成功");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
void OnSocketDisconnect(ServerType servertype, long uid)
|
||||
{
|
||||
switch (servertype)
|
||||
{
|
||||
case ServerType.MainServer:
|
||||
{
|
||||
Console.WriteLine("MainServer连接断开");
|
||||
}
|
||||
break;
|
||||
case ServerType.TcpTunnelServer:
|
||||
{
|
||||
Console.WriteLine("TcpTunnelServer连接断开");
|
||||
Console.WriteLine("TcpTunnelServer,尝试重连");
|
||||
ReConnectTcpTunnelServer();
|
||||
}
|
||||
break;
|
||||
case ServerType.TcpP2PTarget:
|
||||
{
|
||||
Console.WriteLine("TcpP2PTarget连接断开");
|
||||
RemoveTargetSocket(uid);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void ConnectTcpTunnelServer()
|
||||
{
|
||||
App.networkTcp2S = new NetworkHelper(Enum.ServerType.TcpTunnelServer);
|
||||
App.networkTcp2S.Init(IP, tcptunnelport);
|
||||
}
|
||||
|
||||
public void ReConnectTcpTunnelServer()
|
||||
{
|
||||
//TODO 因TEST 暂不重连
|
||||
return;
|
||||
|
||||
if (bTryReConTcpTunnelServer)
|
||||
return;
|
||||
if (App.networkTcp2S != null && App.networkTcp2S.GetClientSocket() != null && App.networkTcp2S.GetClientSocket().Connected)
|
||||
return;
|
||||
bTryReConTcpTunnelServer = true;
|
||||
|
||||
Thread thread = new Thread(ReConnectTcpTunnelServerThread);
|
||||
thread.IsBackground = true;
|
||||
thread.Start();
|
||||
|
||||
}
|
||||
|
||||
private void ReConnectTcpTunnelServerThread()
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
App.networkTcp2S.Init(IP, tcptunnelport);
|
||||
}
|
||||
|
||||
|
||||
#region P2PTarget 管理
|
||||
void AddTargetSocket(NetworkHelper targetSocket)
|
||||
{
|
||||
DictUID2TcpTaret[targetSocket.mUID] = targetSocket;
|
||||
}
|
||||
|
||||
void RemoveTargetSocket(long UID)
|
||||
{
|
||||
if (DictUID2TcpTaret.ContainsKey(UID))
|
||||
{
|
||||
DictUID2TcpTaret.Remove(UID);
|
||||
}
|
||||
}
|
||||
|
||||
NetworkHelper GetTargetSocket(long UID)
|
||||
{
|
||||
if (DictUID2TcpTaret.ContainsKey(UID))
|
||||
{
|
||||
return DictUID2TcpTaret[UID];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送给指定UID消息
|
||||
/// </summary>
|
||||
/// <param name="UID"></param>
|
||||
/// <param name="CMDID"></param>
|
||||
/// <param name="data"></param>
|
||||
public void SendToTargetSocket(long UID,int CMDID,byte[] data)
|
||||
{
|
||||
NetworkHelper target = GetTargetSocket(UID);
|
||||
if (target == null)
|
||||
return;
|
||||
target.SendToServer((int)CMDID, data);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region TCP打洞对连
|
||||
|
||||
public void ConnectTCPTargetP2P(Protobuf_TcpTunnel_DoTunnel_RESP msg, int localPort)
|
||||
{
|
||||
LastlocalPort = localPort;
|
||||
Thread thread = new Thread(ConnectTCPTargetP2PThread);
|
||||
thread.IsBackground = true;
|
||||
thread.Start(msg);
|
||||
}
|
||||
|
||||
public void ConnectTCPTargetP2PThread(object obj)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
int userBindPort = LastlocalPort;
|
||||
Protobuf_TcpTunnel_DoTunnel_RESP msg = (Protobuf_TcpTunnel_DoTunnel_RESP)obj;
|
||||
Console.WriteLine("LocalEndPoint Port:" + userBindPort);
|
||||
NetworkHelper targetSocket = new NetworkHelper(Enum.ServerType.TcpP2PTarget, msg.TargetUID);
|
||||
targetSocket.Init(msg.OtherIP, msg.OtherPort, true, userBindPort);
|
||||
//尝试5次连接
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
try
|
||||
{
|
||||
targetSocket.Connect(msg.OtherIP, msg.OtherPort);
|
||||
Console.WriteLine("Connect:成功{0},{1}", msg.OtherIP, msg.OtherPort);
|
||||
AddTargetSocket(targetSocket);
|
||||
break;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Console.WriteLine("Connect:失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
23
ClientCore/Manager/P2PChat.cs
Normal file
23
ClientCore/Manager/P2PChat.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using AxibugProtobuf;
|
||||
using ClientCore.Common;
|
||||
using ClientCore.Event;
|
||||
using ClientCore.Network;
|
||||
|
||||
namespace ClientCore.Manager
|
||||
{
|
||||
public class P2PChat
|
||||
{
|
||||
public P2PChat()
|
||||
{
|
||||
//NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdChatmsg, RecvChatMsg);
|
||||
}
|
||||
public void SendChatMsg(long UID,string ChatMsg)
|
||||
{
|
||||
Protobuf_TcpP2P_Chat msg = new Protobuf_TcpP2P_Chat()
|
||||
{
|
||||
ChatMsg = ChatMsg,
|
||||
};
|
||||
App.clientMgr.SendToTargetSocket(UID,(int)CommandID.CmdTcpP2PChat ,ProtoBufHelper.Serizlize(msg));
|
||||
}
|
||||
}
|
||||
}
|
61
ClientCore/Manager/P2PTcp.cs
Normal file
61
ClientCore/Manager/P2PTcp.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using AxibugProtobuf;
|
||||
using ClientCore.Common;
|
||||
using ClientCore.Event;
|
||||
using ClientCore.Network;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace ClientCore.Manager
|
||||
{
|
||||
public class P2PTcp
|
||||
{
|
||||
bool bRegToSev = false;
|
||||
public P2PTcp()
|
||||
{
|
||||
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTcptunnelHello, RecvTcptunnelHello);
|
||||
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTcptunnelDo, RecvCmdTcptunnelDo);
|
||||
}
|
||||
|
||||
public void SendHellToSev()
|
||||
{
|
||||
Protobuf_TcpTunnel_HellToSev msg = new Protobuf_TcpTunnel_HellToSev()
|
||||
{
|
||||
UID = App.userMgr.MainPlayer.UID
|
||||
};
|
||||
App.networkTcp2S.SendToServer((int)CommandID.CmdTcptunnelHello, ProtoBufHelper.Serizlize(msg));
|
||||
}
|
||||
|
||||
public void RecvTcptunnelHello(byte[] reqData)
|
||||
{
|
||||
Protobuf_TcpTunnel_HellToSev_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_TcpTunnel_HellToSev_RESP>(reqData);
|
||||
bRegToSev = true;
|
||||
EventSystem.Instance.PostEvent(EEvent.TcpTunnelHelloResp);
|
||||
}
|
||||
|
||||
|
||||
public void SendDoTunnel(long targetUID)
|
||||
{
|
||||
Protobuf_TcpTunnel_DoTunnel msg = new Protobuf_TcpTunnel_DoTunnel()
|
||||
{
|
||||
UID = App.userMgr.MainPlayer.UID,
|
||||
TargetUID = targetUID
|
||||
};
|
||||
App.networkTcp2S.SendToServer((int)CommandID.CmdTcptunnelDo, ProtoBufHelper.Serizlize(msg));
|
||||
}
|
||||
|
||||
public void RecvCmdTcptunnelDo(byte[] reqData)
|
||||
{
|
||||
Protobuf_TcpTunnel_DoTunnel_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_TcpTunnel_DoTunnel_RESP>(reqData);
|
||||
//TODO 打洞
|
||||
Console.WriteLine($"打洞目标信息 {msg.TargetUID} {msg.OtherIP} {msg.OtherPort}");
|
||||
|
||||
int localPort = ((IPEndPoint)App.networkTcp2S.GetClientSocket().LocalEndPoint).Port;
|
||||
|
||||
//断开连接
|
||||
App.networkTcp2S.CloseConntect();
|
||||
|
||||
App.clientMgr.ConnectTCPTargetP2P(msg, localPort);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using AxibugProtobuf;
|
||||
using ClientCore.Common;
|
||||
using ClientCore.Data;
|
||||
using ClientCore.Event;
|
||||
using ClientCore.Network;
|
||||
using System;
|
||||
@ -7,27 +8,41 @@ using System.Security.Cryptography;
|
||||
|
||||
namespace ClientCore.Manager
|
||||
{
|
||||
public class UserInfo
|
||||
{
|
||||
public long UID;//用户ID
|
||||
public string NickName;//昵称
|
||||
public int State;//状态
|
||||
}
|
||||
|
||||
public class UserMgr
|
||||
{
|
||||
public Dictionary<long, UserInfo> DictUID2User = new Dictionary<long, UserInfo>();
|
||||
public UserInfo MainPlayer { get; private set; }
|
||||
public bool bLogin => MainPlayer != null;
|
||||
Dictionary<long, UserInfo> DictUID2User = new Dictionary<long, UserInfo>();
|
||||
public UserMgr()
|
||||
{
|
||||
//网络事件注册
|
||||
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdUserOnlinelist, RecvUserOnlinelist);
|
||||
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdUserJoin, RecvCmdUserJoin);
|
||||
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdUserLeave, RecvGetUserLeave);
|
||||
}
|
||||
|
||||
public void SetMainPlayer(long uid,string account,int state)
|
||||
{
|
||||
MainPlayer = new UserInfo()
|
||||
{
|
||||
State = state,
|
||||
NickName = account,
|
||||
UID = uid
|
||||
};
|
||||
}
|
||||
|
||||
public void Send_GetUserList()
|
||||
{
|
||||
Protobuf_UserList msg = new Protobuf_UserList()
|
||||
{
|
||||
};
|
||||
App.networkMain.SendToServer((int)CommandID.CmdUserOnlinelist, ProtoBufHelper.Serizlize(msg));
|
||||
}
|
||||
|
||||
public void RecvUserOnlinelist(byte[] reqData)
|
||||
{
|
||||
Protobuf_UserList_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_UserList_RESP>(reqData);
|
||||
|
||||
for(int i = 0;i < msg.UserList.Count;i++)
|
||||
{
|
||||
UserMiniInfo mi = msg.UserList[i];
|
||||
@ -86,5 +101,16 @@ namespace ClientCore.Manager
|
||||
EventSystem.Instance.PostEvent(EEvent.UserLeave, UID);
|
||||
}
|
||||
}
|
||||
|
||||
public UserInfo[] GetUserInfo()
|
||||
{
|
||||
UserInfo[] ulist = new UserInfo[DictUID2User.Count];
|
||||
long[] UIDs = DictUID2User.Keys.ToArray();
|
||||
for (int i = 0; i < UIDs.Length; i++)
|
||||
{
|
||||
ulist[i] = DictUID2User[UIDs[i]];
|
||||
}
|
||||
return ulist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
using AxibugProtobuf;
|
||||
using ClientCore.Enum;
|
||||
using ClientCore.Event;
|
||||
using HaoYueNet.ClientNetwork;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -13,7 +15,9 @@ namespace ClientCore.Network
|
||||
/// </summary>
|
||||
public class NetworkHelper : NetworkHelperCore
|
||||
{
|
||||
public NetworkHelper()
|
||||
ServerType mServerType;
|
||||
public long mUID { get; private set; } = -1;
|
||||
public NetworkHelper(ServerType serverType,long UID = -1)
|
||||
{
|
||||
//指定接收服务器数据事件
|
||||
OnDataCallBack += GetDataCallBack;
|
||||
@ -22,15 +26,21 @@ namespace ClientCore.Network
|
||||
//网络库调试信息输出事件,用于打印连接断开,收发事件
|
||||
OnLogOut += NetworkDeBugLog;
|
||||
OnConnected += NetworkConnected;
|
||||
mServerType = serverType;
|
||||
mUID = UID;
|
||||
}
|
||||
|
||||
|
||||
public void NetworkConnected(bool IsConnect)
|
||||
{
|
||||
if (IsConnect)
|
||||
{
|
||||
EventSystem.Instance.PostEvent(EEvent.OnSocketConnect, mServerType, true);
|
||||
NetworkDeBugLog("服务器连接成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
EventSystem.Instance.PostEvent(EEvent.OnSocketConnect, mServerType, false);
|
||||
NetworkDeBugLog("服务器连接失败");
|
||||
//to do 重连逻辑
|
||||
}
|
||||
@ -71,6 +81,7 @@ namespace ClientCore.Network
|
||||
public void OnConnectClose()
|
||||
{
|
||||
NetworkDeBugLog("OnConnectClose");
|
||||
EventSystem.Instance.PostEvent(EEvent.OnSocketDisconnect, mServerType, mUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
@ -28,28 +28,29 @@ namespace AxibugProtobuf {
|
||||
"dG9idWZfTG9naW4SLAoJbG9naW5UeXBlGAEgASgOMhkuQXhpYnVnUHJvdG9i",
|
||||
"dWYuTG9naW5UeXBlEi4KCmRldmljZVR5cGUYAiABKA4yGi5BeGlidWdQcm90",
|
||||
"b2J1Zi5EZXZpY2VUeXBlEg8KB0FjY291bnQYAyABKAkSEAoIUGFzc3dvcmQY",
|
||||
"BCABKAkifwoTUHJvdG9idWZfTG9naW5fUkVTUBINCgVUb2tlbhgBIAEoCRIV",
|
||||
"Cg1MYXN0TG9naW5EYXRlGAIgASgJEg8KB1JlZ0RhdGUYAyABKAkSMQoGU3Rh",
|
||||
"dHVzGAQgASgOMiEuQXhpYnVnUHJvdG9idWYuTG9naW5SZXN1bHRTdGF0dXMi",
|
||||
"IwoQUHJvdG9idWZfQ2hhdE1zZxIPCgdDaGF0TXNnGAEgASgJIkgKFVByb3Rv",
|
||||
"YnVmX0NoYXRNc2dfUkVTUBIQCghOaWNrTmFtZRgBIAEoCRIPCgdDaGF0TXNn",
|
||||
"GAIgASgJEgwKBERhdGUYAyABKAMqzQEKCUNvbW1hbmRJRBIOCgpDTURfREVG",
|
||||
"QVVMEAASDgoJQ01EX0xPR0lOENAPEhAKC0NNRF9DSEFUTVNHEKAfEhgKE0NN",
|
||||
"RF9VU0VSX09OTElORUxJU1QQiCcSEgoNQ01EX1VTRVJfSk9JThCnJxITCg5D",
|
||||
"TURfVVNFUl9MRUFWRRCoJxIaChVDTURfVVNFUl9TVEFURV9VUERBVEUQqScS",
|
||||
"GAoTQ01EX1RDUFRVTk5FTF9IRUxMTxCJJxIVChBDTURfVENQVFVOTkVMX0RP",
|
||||
"EIonKj4KCUVycm9yQ29kZRIQCgxFUlJPUl9ERUZBVUwQABIMCghFUlJPUl9P",
|
||||
"SxABEhEKDUVSUk9SX05PVEZBTkQQZCo+CglMb2dpblR5cGUSDwoLQmFzZURl",
|
||||
"ZmF1bHQQABIOCgpIYW9ZdWVBdXRoEAESBwoDQkYzEAMSBwoDQkY0EAQqSwoK",
|
||||
"RGV2aWNlVHlwZRIWChJEZXZpY2VUeXBlX0RlZmF1bHQQABIGCgJQQxABEgsK",
|
||||
"B0FuZHJvaWQQAhIHCgNJT1MQAxIHCgNQU1YQBCpOChFMb2dpblJlc3VsdFN0",
|
||||
"YXR1cxIhCh1Mb2dpblJlc3VsdFN0YXR1c19CYXNlRGVmYXVsdBAAEgYKAk9L",
|
||||
"EAESDgoKQWNjb3VudEVychACQgJIAWIGcHJvdG8z"));
|
||||
"BCABKAkingEKE1Byb3RvYnVmX0xvZ2luX1JFU1ASDQoFVG9rZW4YASABKAkS",
|
||||
"FQoNTGFzdExvZ2luRGF0ZRgCIAEoCRIPCgdSZWdEYXRlGAMgASgJEjEKBlN0",
|
||||
"YXR1cxgEIAEoDjIhLkF4aWJ1Z1Byb3RvYnVmLkxvZ2luUmVzdWx0U3RhdHVz",
|
||||
"EgsKA1VJRBgFIAEoAxIQCghOaWNrTmFtZRgGIAEoCSIjChBQcm90b2J1Zl9D",
|
||||
"aGF0TXNnEg8KB0NoYXRNc2cYASABKAkiSAoVUHJvdG9idWZfQ2hhdE1zZ19S",
|
||||
"RVNQEhAKCE5pY2tOYW1lGAEgASgJEg8KB0NoYXRNc2cYAiABKAkSDAoERGF0",
|
||||
"ZRgDIAEoAyrkAQoJQ29tbWFuZElEEg4KCkNNRF9ERUZBVUwQABIOCglDTURf",
|
||||
"TE9HSU4Q0A8SEAoLQ01EX0NIQVRNU0cQoB8SGAoTQ01EX1VTRVJfT05MSU5F",
|
||||
"TElTVBCIJxISCg1DTURfVVNFUl9KT0lOEKcnEhMKDkNNRF9VU0VSX0xFQVZF",
|
||||
"EKgnEhoKFUNNRF9VU0VSX1NUQVRFX1VQREFURRCpJxIYChNDTURfVENQVFVO",
|
||||
"TkVMX0hFTExPEIknEhUKEENNRF9UQ1BUVU5ORUxfRE8QiicSFQoQQ01EX1RD",
|
||||
"UF9QMlBfQ0hBVBCRTio+CglFcnJvckNvZGUSEAoMRVJST1JfREVGQVVMEAAS",
|
||||
"DAoIRVJST1JfT0sQARIRCg1FUlJPUl9OT1RGSU5EEGQqPgoJTG9naW5UeXBl",
|
||||
"Eg8KC0Jhc2VEZWZhdWx0EAASDgoKSGFvWXVlQXV0aBABEgcKA0JGMxADEgcK",
|
||||
"A0JGNBAEKksKCkRldmljZVR5cGUSFgoSRGV2aWNlVHlwZV9EZWZhdWx0EAAS",
|
||||
"BgoCUEMQARILCgdBbmRyb2lkEAISBwoDSU9TEAMSBwoDUFNWEAQqTgoRTG9n",
|
||||
"aW5SZXN1bHRTdGF0dXMSIQodTG9naW5SZXN1bHRTdGF0dXNfQmFzZURlZmF1",
|
||||
"bHQQABIGCgJPSxABEg4KCkFjY291bnRFcnIQAkICSAFiBnByb3RvMw=="));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { },
|
||||
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::AxibugProtobuf.CommandID), typeof(global::AxibugProtobuf.ErrorCode), typeof(global::AxibugProtobuf.LoginType), typeof(global::AxibugProtobuf.DeviceType), typeof(global::AxibugProtobuf.LoginResultStatus), }, null, new pbr::GeneratedClrTypeInfo[] {
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login), global::AxibugProtobuf.Protobuf_Login.Parser, new[]{ "LoginType", "DeviceType", "Account", "Password" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login_RESP), global::AxibugProtobuf.Protobuf_Login_RESP.Parser, new[]{ "Token", "LastLoginDate", "RegDate", "Status" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login_RESP), global::AxibugProtobuf.Protobuf_Login_RESP.Parser, new[]{ "Token", "LastLoginDate", "RegDate", "Status", "UID", "NickName" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg), global::AxibugProtobuf.Protobuf_ChatMsg.Parser, new[]{ "ChatMsg" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg_RESP), global::AxibugProtobuf.Protobuf_ChatMsg_RESP.Parser, new[]{ "NickName", "ChatMsg", "Date" }, null, null, null, null)
|
||||
}));
|
||||
@ -95,6 +96,10 @@ namespace AxibugProtobuf {
|
||||
///TCP打洞请求 下行 对应 Protobuf_TcpTunnel_DoTunnel | Protobuf_TcpTunnel_DoTunnel_RESP
|
||||
/// </summary>
|
||||
[pbr::OriginalName("CMD_TCPTUNNEL_DO")] CmdTcptunnelDo = 5002,
|
||||
/// <summary>
|
||||
///TCPP2P聊天 Protobuf_TcpP2P_Chat
|
||||
/// </summary>
|
||||
[pbr::OriginalName("CMD_TCP_P2P_CHAT")] CmdTcpP2PChat = 10001,
|
||||
}
|
||||
|
||||
public enum ErrorCode {
|
||||
@ -109,7 +114,7 @@ namespace AxibugProtobuf {
|
||||
/// <summary>
|
||||
///用户不存在
|
||||
/// </summary>
|
||||
[pbr::OriginalName("ERROR_NOTFAND")] ErrorNotfand = 100,
|
||||
[pbr::OriginalName("ERROR_NOTFIND")] ErrorNotfind = 100,
|
||||
}
|
||||
|
||||
public enum LoginType {
|
||||
@ -476,6 +481,8 @@ namespace AxibugProtobuf {
|
||||
lastLoginDate_ = other.lastLoginDate_;
|
||||
regDate_ = other.regDate_;
|
||||
status_ = other.status_;
|
||||
uID_ = other.uID_;
|
||||
nickName_ = other.nickName_;
|
||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||
}
|
||||
|
||||
@ -540,6 +547,34 @@ namespace AxibugProtobuf {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "UID" field.</summary>
|
||||
public const int UIDFieldNumber = 5;
|
||||
private long uID_;
|
||||
/// <summary>
|
||||
///UID
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public long UID {
|
||||
get { return uID_; }
|
||||
set {
|
||||
uID_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "NickName" field.</summary>
|
||||
public const int NickNameFieldNumber = 6;
|
||||
private string nickName_ = "";
|
||||
/// <summary>
|
||||
///昵称
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public string NickName {
|
||||
get { return nickName_; }
|
||||
set {
|
||||
nickName_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public override bool Equals(object other) {
|
||||
return Equals(other as Protobuf_Login_RESP);
|
||||
@ -557,6 +592,8 @@ namespace AxibugProtobuf {
|
||||
if (LastLoginDate != other.LastLoginDate) return false;
|
||||
if (RegDate != other.RegDate) return false;
|
||||
if (Status != other.Status) return false;
|
||||
if (UID != other.UID) return false;
|
||||
if (NickName != other.NickName) return false;
|
||||
return Equals(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
@ -567,6 +604,8 @@ namespace AxibugProtobuf {
|
||||
if (LastLoginDate.Length != 0) hash ^= LastLoginDate.GetHashCode();
|
||||
if (RegDate.Length != 0) hash ^= RegDate.GetHashCode();
|
||||
if (Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) hash ^= Status.GetHashCode();
|
||||
if (UID != 0L) hash ^= UID.GetHashCode();
|
||||
if (NickName.Length != 0) hash ^= NickName.GetHashCode();
|
||||
if (_unknownFields != null) {
|
||||
hash ^= _unknownFields.GetHashCode();
|
||||
}
|
||||
@ -599,6 +638,14 @@ namespace AxibugProtobuf {
|
||||
output.WriteRawTag(32);
|
||||
output.WriteEnum((int) Status);
|
||||
}
|
||||
if (UID != 0L) {
|
||||
output.WriteRawTag(40);
|
||||
output.WriteInt64(UID);
|
||||
}
|
||||
if (NickName.Length != 0) {
|
||||
output.WriteRawTag(50);
|
||||
output.WriteString(NickName);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(output);
|
||||
}
|
||||
@ -624,6 +671,14 @@ namespace AxibugProtobuf {
|
||||
output.WriteRawTag(32);
|
||||
output.WriteEnum((int) Status);
|
||||
}
|
||||
if (UID != 0L) {
|
||||
output.WriteRawTag(40);
|
||||
output.WriteInt64(UID);
|
||||
}
|
||||
if (NickName.Length != 0) {
|
||||
output.WriteRawTag(50);
|
||||
output.WriteString(NickName);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(ref output);
|
||||
}
|
||||
@ -645,6 +700,12 @@ namespace AxibugProtobuf {
|
||||
if (Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Status);
|
||||
}
|
||||
if (UID != 0L) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt64Size(UID);
|
||||
}
|
||||
if (NickName.Length != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(NickName);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
size += _unknownFields.CalculateSize();
|
||||
}
|
||||
@ -668,6 +729,12 @@ namespace AxibugProtobuf {
|
||||
if (other.Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) {
|
||||
Status = other.Status;
|
||||
}
|
||||
if (other.UID != 0L) {
|
||||
UID = other.UID;
|
||||
}
|
||||
if (other.NickName.Length != 0) {
|
||||
NickName = other.NickName;
|
||||
}
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
@ -698,6 +765,14 @@ namespace AxibugProtobuf {
|
||||
Status = (global::AxibugProtobuf.LoginResultStatus) input.ReadEnum();
|
||||
break;
|
||||
}
|
||||
case 40: {
|
||||
UID = input.ReadInt64();
|
||||
break;
|
||||
}
|
||||
case 50: {
|
||||
NickName = input.ReadString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -728,6 +803,14 @@ namespace AxibugProtobuf {
|
||||
Status = (global::AxibugProtobuf.LoginResultStatus) input.ReadEnum();
|
||||
break;
|
||||
}
|
||||
case 40: {
|
||||
UID = input.ReadInt64();
|
||||
break;
|
||||
}
|
||||
case 50: {
|
||||
NickName = input.ReadString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,15 +30,17 @@ namespace AxibugProtobuf {
|
||||
"Zl9UY3BUdW5uZWxfRG9UdW5uZWwSCwoDVUlEGAEgASgDEhEKCXRhcmdldFVJ",
|
||||
"RBgCIAEoAyJ3CiBQcm90b2J1Zl9UY3BUdW5uZWxfRG9UdW5uZWxfUkVTUBIR",
|
||||
"Cgl0YXJnZXRVSUQYASABKAMSDAoEbXlJUBgCIAEoCRIOCgZteVBvcnQYAyAB",
|
||||
"KAUSDwoHb3RoZXJJUBgEIAEoCRIRCglvdGhlclBvcnQYBSABKAVCAkgBYgZw",
|
||||
"cm90bzM="));
|
||||
"KAUSDwoHb3RoZXJJUBgEIAEoCRIRCglvdGhlclBvcnQYBSABKAUiJwoUUHJv",
|
||||
"dG9idWZfVGNwUDJQX0NoYXQSDwoHQ2hhdE1zZxgBIAEoCUICSAFiBnByb3Rv",
|
||||
"Mw=="));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { },
|
||||
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_TcpTunnel_HellToSev), global::AxibugProtobuf.Protobuf_TcpTunnel_HellToSev.Parser, new[]{ "UID" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_TcpTunnel_HellToSev_RESP), global::AxibugProtobuf.Protobuf_TcpTunnel_HellToSev_RESP.Parser, null, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_TcpTunnel_DoTunnel), global::AxibugProtobuf.Protobuf_TcpTunnel_DoTunnel.Parser, new[]{ "UID", "TargetUID" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_TcpTunnel_DoTunnel_RESP), global::AxibugProtobuf.Protobuf_TcpTunnel_DoTunnel_RESP.Parser, new[]{ "TargetUID", "MyIP", "MyPort", "OtherIP", "OtherPort" }, null, null, null, null)
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_TcpTunnel_DoTunnel_RESP), global::AxibugProtobuf.Protobuf_TcpTunnel_DoTunnel_RESP.Parser, new[]{ "TargetUID", "MyIP", "MyPort", "OtherIP", "OtherPort" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_TcpP2P_Chat), global::AxibugProtobuf.Protobuf_TcpP2P_Chat.Parser, new[]{ "ChatMsg" }, null, null, null, null)
|
||||
}));
|
||||
}
|
||||
#endregion
|
||||
@ -913,6 +915,184 @@ namespace AxibugProtobuf {
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///TCPP2P聊天
|
||||
/// </summary>
|
||||
public sealed partial class Protobuf_TcpP2P_Chat : pb::IMessage<Protobuf_TcpP2P_Chat>
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
, pb::IBufferMessage
|
||||
#endif
|
||||
{
|
||||
private static readonly pb::MessageParser<Protobuf_TcpP2P_Chat> _parser = new pb::MessageParser<Protobuf_TcpP2P_Chat>(() => new Protobuf_TcpP2P_Chat());
|
||||
private pb::UnknownFieldSet _unknownFields;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public static pb::MessageParser<Protobuf_TcpP2P_Chat> Parser { get { return _parser; } }
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public static pbr::MessageDescriptor Descriptor {
|
||||
get { return global::AxibugProtobuf.ProtobufTcpTunnelReflection.Descriptor.MessageTypes[4]; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
||||
get { return Descriptor; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public Protobuf_TcpP2P_Chat() {
|
||||
OnConstruction();
|
||||
}
|
||||
|
||||
partial void OnConstruction();
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public Protobuf_TcpP2P_Chat(Protobuf_TcpP2P_Chat other) : this() {
|
||||
chatMsg_ = other.chatMsg_;
|
||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public Protobuf_TcpP2P_Chat Clone() {
|
||||
return new Protobuf_TcpP2P_Chat(this);
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "ChatMsg" field.</summary>
|
||||
public const int ChatMsgFieldNumber = 1;
|
||||
private string chatMsg_ = "";
|
||||
/// <summary>
|
||||
///消息
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public string ChatMsg {
|
||||
get { return chatMsg_; }
|
||||
set {
|
||||
chatMsg_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public override bool Equals(object other) {
|
||||
return Equals(other as Protobuf_TcpP2P_Chat);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public bool Equals(Protobuf_TcpP2P_Chat other) {
|
||||
if (ReferenceEquals(other, null)) {
|
||||
return false;
|
||||
}
|
||||
if (ReferenceEquals(other, this)) {
|
||||
return true;
|
||||
}
|
||||
if (ChatMsg != other.ChatMsg) return false;
|
||||
return Equals(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public override int GetHashCode() {
|
||||
int hash = 1;
|
||||
if (ChatMsg.Length != 0) hash ^= ChatMsg.GetHashCode();
|
||||
if (_unknownFields != null) {
|
||||
hash ^= _unknownFields.GetHashCode();
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public override string ToString() {
|
||||
return pb::JsonFormatter.ToDiagnosticString(this);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public void WriteTo(pb::CodedOutputStream output) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
output.WriteRawMessage(this);
|
||||
#else
|
||||
if (ChatMsg.Length != 0) {
|
||||
output.WriteRawTag(10);
|
||||
output.WriteString(ChatMsg);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(output);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
|
||||
if (ChatMsg.Length != 0) {
|
||||
output.WriteRawTag(10);
|
||||
output.WriteString(ChatMsg);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(ref output);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public int CalculateSize() {
|
||||
int size = 0;
|
||||
if (ChatMsg.Length != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(ChatMsg);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
size += _unknownFields.CalculateSize();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public void MergeFrom(Protobuf_TcpP2P_Chat other) {
|
||||
if (other == null) {
|
||||
return;
|
||||
}
|
||||
if (other.ChatMsg.Length != 0) {
|
||||
ChatMsg = other.ChatMsg;
|
||||
}
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public void MergeFrom(pb::CodedInputStream input) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
input.ReadRawMessage(this);
|
||||
#else
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
|
||||
break;
|
||||
case 10: {
|
||||
ChatMsg = input.ReadString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
|
||||
break;
|
||||
case 10: {
|
||||
ChatMsg = input.ReadString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
@ -28,28 +28,29 @@ namespace AxibugProtobuf {
|
||||
"dG9idWZfTG9naW4SLAoJbG9naW5UeXBlGAEgASgOMhkuQXhpYnVnUHJvdG9i",
|
||||
"dWYuTG9naW5UeXBlEi4KCmRldmljZVR5cGUYAiABKA4yGi5BeGlidWdQcm90",
|
||||
"b2J1Zi5EZXZpY2VUeXBlEg8KB0FjY291bnQYAyABKAkSEAoIUGFzc3dvcmQY",
|
||||
"BCABKAkifwoTUHJvdG9idWZfTG9naW5fUkVTUBINCgVUb2tlbhgBIAEoCRIV",
|
||||
"Cg1MYXN0TG9naW5EYXRlGAIgASgJEg8KB1JlZ0RhdGUYAyABKAkSMQoGU3Rh",
|
||||
"dHVzGAQgASgOMiEuQXhpYnVnUHJvdG9idWYuTG9naW5SZXN1bHRTdGF0dXMi",
|
||||
"IwoQUHJvdG9idWZfQ2hhdE1zZxIPCgdDaGF0TXNnGAEgASgJIkgKFVByb3Rv",
|
||||
"YnVmX0NoYXRNc2dfUkVTUBIQCghOaWNrTmFtZRgBIAEoCRIPCgdDaGF0TXNn",
|
||||
"GAIgASgJEgwKBERhdGUYAyABKAMqzQEKCUNvbW1hbmRJRBIOCgpDTURfREVG",
|
||||
"QVVMEAASDgoJQ01EX0xPR0lOENAPEhAKC0NNRF9DSEFUTVNHEKAfEhgKE0NN",
|
||||
"RF9VU0VSX09OTElORUxJU1QQiCcSEgoNQ01EX1VTRVJfSk9JThCnJxITCg5D",
|
||||
"TURfVVNFUl9MRUFWRRCoJxIaChVDTURfVVNFUl9TVEFURV9VUERBVEUQqScS",
|
||||
"GAoTQ01EX1RDUFRVTk5FTF9IRUxMTxCJJxIVChBDTURfVENQVFVOTkVMX0RP",
|
||||
"EIonKj4KCUVycm9yQ29kZRIQCgxFUlJPUl9ERUZBVUwQABIMCghFUlJPUl9P",
|
||||
"SxABEhEKDUVSUk9SX05PVEZBTkQQZCo+CglMb2dpblR5cGUSDwoLQmFzZURl",
|
||||
"ZmF1bHQQABIOCgpIYW9ZdWVBdXRoEAESBwoDQkYzEAMSBwoDQkY0EAQqSwoK",
|
||||
"RGV2aWNlVHlwZRIWChJEZXZpY2VUeXBlX0RlZmF1bHQQABIGCgJQQxABEgsK",
|
||||
"B0FuZHJvaWQQAhIHCgNJT1MQAxIHCgNQU1YQBCpOChFMb2dpblJlc3VsdFN0",
|
||||
"YXR1cxIhCh1Mb2dpblJlc3VsdFN0YXR1c19CYXNlRGVmYXVsdBAAEgYKAk9L",
|
||||
"EAESDgoKQWNjb3VudEVychACQgJIAWIGcHJvdG8z"));
|
||||
"BCABKAkingEKE1Byb3RvYnVmX0xvZ2luX1JFU1ASDQoFVG9rZW4YASABKAkS",
|
||||
"FQoNTGFzdExvZ2luRGF0ZRgCIAEoCRIPCgdSZWdEYXRlGAMgASgJEjEKBlN0",
|
||||
"YXR1cxgEIAEoDjIhLkF4aWJ1Z1Byb3RvYnVmLkxvZ2luUmVzdWx0U3RhdHVz",
|
||||
"EgsKA1VJRBgFIAEoAxIQCghOaWNrTmFtZRgGIAEoCSIjChBQcm90b2J1Zl9D",
|
||||
"aGF0TXNnEg8KB0NoYXRNc2cYASABKAkiSAoVUHJvdG9idWZfQ2hhdE1zZ19S",
|
||||
"RVNQEhAKCE5pY2tOYW1lGAEgASgJEg8KB0NoYXRNc2cYAiABKAkSDAoERGF0",
|
||||
"ZRgDIAEoAyrkAQoJQ29tbWFuZElEEg4KCkNNRF9ERUZBVUwQABIOCglDTURf",
|
||||
"TE9HSU4Q0A8SEAoLQ01EX0NIQVRNU0cQoB8SGAoTQ01EX1VTRVJfT05MSU5F",
|
||||
"TElTVBCIJxISCg1DTURfVVNFUl9KT0lOEKcnEhMKDkNNRF9VU0VSX0xFQVZF",
|
||||
"EKgnEhoKFUNNRF9VU0VSX1NUQVRFX1VQREFURRCpJxIYChNDTURfVENQVFVO",
|
||||
"TkVMX0hFTExPEIknEhUKEENNRF9UQ1BUVU5ORUxfRE8QiicSFQoQQ01EX1RD",
|
||||
"UF9QMlBfQ0hBVBCRTio+CglFcnJvckNvZGUSEAoMRVJST1JfREVGQVVMEAAS",
|
||||
"DAoIRVJST1JfT0sQARIRCg1FUlJPUl9OT1RGSU5EEGQqPgoJTG9naW5UeXBl",
|
||||
"Eg8KC0Jhc2VEZWZhdWx0EAASDgoKSGFvWXVlQXV0aBABEgcKA0JGMxADEgcK",
|
||||
"A0JGNBAEKksKCkRldmljZVR5cGUSFgoSRGV2aWNlVHlwZV9EZWZhdWx0EAAS",
|
||||
"BgoCUEMQARILCgdBbmRyb2lkEAISBwoDSU9TEAMSBwoDUFNWEAQqTgoRTG9n",
|
||||
"aW5SZXN1bHRTdGF0dXMSIQodTG9naW5SZXN1bHRTdGF0dXNfQmFzZURlZmF1",
|
||||
"bHQQABIGCgJPSxABEg4KCkFjY291bnRFcnIQAkICSAFiBnByb3RvMw=="));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { },
|
||||
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::AxibugProtobuf.CommandID), typeof(global::AxibugProtobuf.ErrorCode), typeof(global::AxibugProtobuf.LoginType), typeof(global::AxibugProtobuf.DeviceType), typeof(global::AxibugProtobuf.LoginResultStatus), }, null, new pbr::GeneratedClrTypeInfo[] {
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login), global::AxibugProtobuf.Protobuf_Login.Parser, new[]{ "LoginType", "DeviceType", "Account", "Password" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login_RESP), global::AxibugProtobuf.Protobuf_Login_RESP.Parser, new[]{ "Token", "LastLoginDate", "RegDate", "Status" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login_RESP), global::AxibugProtobuf.Protobuf_Login_RESP.Parser, new[]{ "Token", "LastLoginDate", "RegDate", "Status", "UID", "NickName" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg), global::AxibugProtobuf.Protobuf_ChatMsg.Parser, new[]{ "ChatMsg" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg_RESP), global::AxibugProtobuf.Protobuf_ChatMsg_RESP.Parser, new[]{ "NickName", "ChatMsg", "Date" }, null, null, null, null)
|
||||
}));
|
||||
@ -95,6 +96,10 @@ namespace AxibugProtobuf {
|
||||
///TCP打洞请求 下行 对应 Protobuf_TcpTunnel_DoTunnel | Protobuf_TcpTunnel_DoTunnel_RESP
|
||||
/// </summary>
|
||||
[pbr::OriginalName("CMD_TCPTUNNEL_DO")] CmdTcptunnelDo = 5002,
|
||||
/// <summary>
|
||||
///TCPP2P聊天 Protobuf_TcpP2P_Chat
|
||||
/// </summary>
|
||||
[pbr::OriginalName("CMD_TCP_P2P_CHAT")] CmdTcpP2PChat = 10001,
|
||||
}
|
||||
|
||||
public enum ErrorCode {
|
||||
@ -109,7 +114,7 @@ namespace AxibugProtobuf {
|
||||
/// <summary>
|
||||
///用户不存在
|
||||
/// </summary>
|
||||
[pbr::OriginalName("ERROR_NOTFAND")] ErrorNotfand = 100,
|
||||
[pbr::OriginalName("ERROR_NOTFIND")] ErrorNotfind = 100,
|
||||
}
|
||||
|
||||
public enum LoginType {
|
||||
@ -476,6 +481,8 @@ namespace AxibugProtobuf {
|
||||
lastLoginDate_ = other.lastLoginDate_;
|
||||
regDate_ = other.regDate_;
|
||||
status_ = other.status_;
|
||||
uID_ = other.uID_;
|
||||
nickName_ = other.nickName_;
|
||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||
}
|
||||
|
||||
@ -540,6 +547,34 @@ namespace AxibugProtobuf {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "UID" field.</summary>
|
||||
public const int UIDFieldNumber = 5;
|
||||
private long uID_;
|
||||
/// <summary>
|
||||
///UID
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public long UID {
|
||||
get { return uID_; }
|
||||
set {
|
||||
uID_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "NickName" field.</summary>
|
||||
public const int NickNameFieldNumber = 6;
|
||||
private string nickName_ = "";
|
||||
/// <summary>
|
||||
///昵称
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public string NickName {
|
||||
get { return nickName_; }
|
||||
set {
|
||||
nickName_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public override bool Equals(object other) {
|
||||
return Equals(other as Protobuf_Login_RESP);
|
||||
@ -557,6 +592,8 @@ namespace AxibugProtobuf {
|
||||
if (LastLoginDate != other.LastLoginDate) return false;
|
||||
if (RegDate != other.RegDate) return false;
|
||||
if (Status != other.Status) return false;
|
||||
if (UID != other.UID) return false;
|
||||
if (NickName != other.NickName) return false;
|
||||
return Equals(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
@ -567,6 +604,8 @@ namespace AxibugProtobuf {
|
||||
if (LastLoginDate.Length != 0) hash ^= LastLoginDate.GetHashCode();
|
||||
if (RegDate.Length != 0) hash ^= RegDate.GetHashCode();
|
||||
if (Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) hash ^= Status.GetHashCode();
|
||||
if (UID != 0L) hash ^= UID.GetHashCode();
|
||||
if (NickName.Length != 0) hash ^= NickName.GetHashCode();
|
||||
if (_unknownFields != null) {
|
||||
hash ^= _unknownFields.GetHashCode();
|
||||
}
|
||||
@ -599,6 +638,14 @@ namespace AxibugProtobuf {
|
||||
output.WriteRawTag(32);
|
||||
output.WriteEnum((int) Status);
|
||||
}
|
||||
if (UID != 0L) {
|
||||
output.WriteRawTag(40);
|
||||
output.WriteInt64(UID);
|
||||
}
|
||||
if (NickName.Length != 0) {
|
||||
output.WriteRawTag(50);
|
||||
output.WriteString(NickName);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(output);
|
||||
}
|
||||
@ -624,6 +671,14 @@ namespace AxibugProtobuf {
|
||||
output.WriteRawTag(32);
|
||||
output.WriteEnum((int) Status);
|
||||
}
|
||||
if (UID != 0L) {
|
||||
output.WriteRawTag(40);
|
||||
output.WriteInt64(UID);
|
||||
}
|
||||
if (NickName.Length != 0) {
|
||||
output.WriteRawTag(50);
|
||||
output.WriteString(NickName);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(ref output);
|
||||
}
|
||||
@ -645,6 +700,12 @@ namespace AxibugProtobuf {
|
||||
if (Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Status);
|
||||
}
|
||||
if (UID != 0L) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt64Size(UID);
|
||||
}
|
||||
if (NickName.Length != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(NickName);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
size += _unknownFields.CalculateSize();
|
||||
}
|
||||
@ -668,6 +729,12 @@ namespace AxibugProtobuf {
|
||||
if (other.Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) {
|
||||
Status = other.Status;
|
||||
}
|
||||
if (other.UID != 0L) {
|
||||
UID = other.UID;
|
||||
}
|
||||
if (other.NickName.Length != 0) {
|
||||
NickName = other.NickName;
|
||||
}
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
@ -698,6 +765,14 @@ namespace AxibugProtobuf {
|
||||
Status = (global::AxibugProtobuf.LoginResultStatus) input.ReadEnum();
|
||||
break;
|
||||
}
|
||||
case 40: {
|
||||
UID = input.ReadInt64();
|
||||
break;
|
||||
}
|
||||
case 50: {
|
||||
NickName = input.ReadString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -728,6 +803,14 @@ namespace AxibugProtobuf {
|
||||
Status = (global::AxibugProtobuf.LoginResultStatus) input.ReadEnum();
|
||||
break;
|
||||
}
|
||||
case 40: {
|
||||
UID = input.ReadInt64();
|
||||
break;
|
||||
}
|
||||
case 50: {
|
||||
NickName = input.ReadString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,15 +30,17 @@ namespace AxibugProtobuf {
|
||||
"Zl9UY3BUdW5uZWxfRG9UdW5uZWwSCwoDVUlEGAEgASgDEhEKCXRhcmdldFVJ",
|
||||
"RBgCIAEoAyJ3CiBQcm90b2J1Zl9UY3BUdW5uZWxfRG9UdW5uZWxfUkVTUBIR",
|
||||
"Cgl0YXJnZXRVSUQYASABKAMSDAoEbXlJUBgCIAEoCRIOCgZteVBvcnQYAyAB",
|
||||
"KAUSDwoHb3RoZXJJUBgEIAEoCRIRCglvdGhlclBvcnQYBSABKAVCAkgBYgZw",
|
||||
"cm90bzM="));
|
||||
"KAUSDwoHb3RoZXJJUBgEIAEoCRIRCglvdGhlclBvcnQYBSABKAUiJwoUUHJv",
|
||||
"dG9idWZfVGNwUDJQX0NoYXQSDwoHQ2hhdE1zZxgBIAEoCUICSAFiBnByb3Rv",
|
||||
"Mw=="));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { },
|
||||
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_TcpTunnel_HellToSev), global::AxibugProtobuf.Protobuf_TcpTunnel_HellToSev.Parser, new[]{ "UID" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_TcpTunnel_HellToSev_RESP), global::AxibugProtobuf.Protobuf_TcpTunnel_HellToSev_RESP.Parser, null, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_TcpTunnel_DoTunnel), global::AxibugProtobuf.Protobuf_TcpTunnel_DoTunnel.Parser, new[]{ "UID", "TargetUID" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_TcpTunnel_DoTunnel_RESP), global::AxibugProtobuf.Protobuf_TcpTunnel_DoTunnel_RESP.Parser, new[]{ "TargetUID", "MyIP", "MyPort", "OtherIP", "OtherPort" }, null, null, null, null)
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_TcpTunnel_DoTunnel_RESP), global::AxibugProtobuf.Protobuf_TcpTunnel_DoTunnel_RESP.Parser, new[]{ "TargetUID", "MyIP", "MyPort", "OtherIP", "OtherPort" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_TcpP2P_Chat), global::AxibugProtobuf.Protobuf_TcpP2P_Chat.Parser, new[]{ "ChatMsg" }, null, null, null, null)
|
||||
}));
|
||||
}
|
||||
#endregion
|
||||
@ -913,6 +915,184 @@ namespace AxibugProtobuf {
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///TCPP2P聊天
|
||||
/// </summary>
|
||||
public sealed partial class Protobuf_TcpP2P_Chat : pb::IMessage<Protobuf_TcpP2P_Chat>
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
, pb::IBufferMessage
|
||||
#endif
|
||||
{
|
||||
private static readonly pb::MessageParser<Protobuf_TcpP2P_Chat> _parser = new pb::MessageParser<Protobuf_TcpP2P_Chat>(() => new Protobuf_TcpP2P_Chat());
|
||||
private pb::UnknownFieldSet _unknownFields;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public static pb::MessageParser<Protobuf_TcpP2P_Chat> Parser { get { return _parser; } }
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public static pbr::MessageDescriptor Descriptor {
|
||||
get { return global::AxibugProtobuf.ProtobufTcpTunnelReflection.Descriptor.MessageTypes[4]; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
||||
get { return Descriptor; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public Protobuf_TcpP2P_Chat() {
|
||||
OnConstruction();
|
||||
}
|
||||
|
||||
partial void OnConstruction();
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public Protobuf_TcpP2P_Chat(Protobuf_TcpP2P_Chat other) : this() {
|
||||
chatMsg_ = other.chatMsg_;
|
||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public Protobuf_TcpP2P_Chat Clone() {
|
||||
return new Protobuf_TcpP2P_Chat(this);
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "ChatMsg" field.</summary>
|
||||
public const int ChatMsgFieldNumber = 1;
|
||||
private string chatMsg_ = "";
|
||||
/// <summary>
|
||||
///消息
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public string ChatMsg {
|
||||
get { return chatMsg_; }
|
||||
set {
|
||||
chatMsg_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public override bool Equals(object other) {
|
||||
return Equals(other as Protobuf_TcpP2P_Chat);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public bool Equals(Protobuf_TcpP2P_Chat other) {
|
||||
if (ReferenceEquals(other, null)) {
|
||||
return false;
|
||||
}
|
||||
if (ReferenceEquals(other, this)) {
|
||||
return true;
|
||||
}
|
||||
if (ChatMsg != other.ChatMsg) return false;
|
||||
return Equals(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public override int GetHashCode() {
|
||||
int hash = 1;
|
||||
if (ChatMsg.Length != 0) hash ^= ChatMsg.GetHashCode();
|
||||
if (_unknownFields != null) {
|
||||
hash ^= _unknownFields.GetHashCode();
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public override string ToString() {
|
||||
return pb::JsonFormatter.ToDiagnosticString(this);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public void WriteTo(pb::CodedOutputStream output) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
output.WriteRawMessage(this);
|
||||
#else
|
||||
if (ChatMsg.Length != 0) {
|
||||
output.WriteRawTag(10);
|
||||
output.WriteString(ChatMsg);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(output);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
|
||||
if (ChatMsg.Length != 0) {
|
||||
output.WriteRawTag(10);
|
||||
output.WriteString(ChatMsg);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(ref output);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public int CalculateSize() {
|
||||
int size = 0;
|
||||
if (ChatMsg.Length != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(ChatMsg);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
size += _unknownFields.CalculateSize();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public void MergeFrom(Protobuf_TcpP2P_Chat other) {
|
||||
if (other == null) {
|
||||
return;
|
||||
}
|
||||
if (other.ChatMsg.Length != 0) {
|
||||
ChatMsg = other.ChatMsg;
|
||||
}
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public void MergeFrom(pb::CodedInputStream input) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
input.ReadRawMessage(this);
|
||||
#else
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
|
||||
break;
|
||||
case 10: {
|
||||
ChatMsg = input.ReadString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
|
||||
break;
|
||||
case 10: {
|
||||
ChatMsg = input.ReadString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ enum CommandID
|
||||
|
||||
CMD_TCPTUNNEL_HELLO = 5001; //TCP打洞请求 上行 | 下行 对应 Protobuf_TcpTunnel_HellToSev | Protobuf_TcpTunnel_HellToSev_RESP
|
||||
CMD_TCPTUNNEL_DO = 5002; //TCP打洞请求 下行 对应 Protobuf_TcpTunnel_DoTunnel | Protobuf_TcpTunnel_DoTunnel_RESP
|
||||
|
||||
CMD_TCP_P2P_CHAT = 10001; //TCPP2P聊天 Protobuf_TcpP2P_Chat
|
||||
}
|
||||
|
||||
enum ErrorCode
|
||||
@ -66,6 +68,8 @@ message Protobuf_Login_RESP
|
||||
string LastLoginDate = 2;//上次登录时间(只用于呈现的字符串,若界面需求需要)
|
||||
string RegDate = 3;//注册时间(只用于呈现的字符串,若界面需求需要)
|
||||
LoginResultStatus Status = 4;//账号状态 (预留) [1]正常[0]被禁封
|
||||
int64 UID = 5;//UID
|
||||
string NickName = 6;//昵称
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,3 +30,13 @@ message Protobuf_TcpTunnel_DoTunnel_RESP
|
||||
string otherIP = 4;//对方的IP
|
||||
int32 otherPort = 5;//对方的Port
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////TCP P2P聊天//////////////////
|
||||
|
||||
//TCPP2P聊天
|
||||
message Protobuf_TcpP2P_Chat
|
||||
{
|
||||
string ChatMsg = 1;//消息
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using ServerCore.Manager;
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
ServerManager.InitServer(23846, 23847);
|
||||
|
||||
while (true)
|
||||
@ -12,6 +13,9 @@ while (true)
|
||||
case "list":
|
||||
Console.WriteLine("当前在线:" + ServerManager.g_ClientMgr.GetOnlineClientCount());
|
||||
break;
|
||||
case "tlist":
|
||||
Console.WriteLine("当前TcpTunnel在线:" + ServerManager.g_TcpTunnelMgr.GetOnlineClientCount());
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("未知命令" + CommandStr);
|
||||
break;
|
||||
|
14
ServerCore/Common/Enum/CommEnum.cs
Normal file
14
ServerCore/Common/Enum/CommEnum.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServerCore.Common.Enum
|
||||
{
|
||||
public enum ServerType
|
||||
{
|
||||
MainServer,
|
||||
TcpTunnelServer
|
||||
}
|
||||
}
|
@ -10,6 +10,10 @@ namespace ServerCore.Event
|
||||
{
|
||||
// 添加你自己需要的事件类型
|
||||
OnUserJoin,
|
||||
OnUserLeave
|
||||
OnUserLeave,
|
||||
|
||||
|
||||
//连接管理
|
||||
OnSocketDisconnect,
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AxibugProtobuf;
|
||||
using ServerCore.Common.Enum;
|
||||
using ServerCore.Event;
|
||||
using System.Net.Sockets;
|
||||
using System.Timers;
|
||||
@ -26,40 +27,51 @@ namespace ServerCore.Manager
|
||||
private long _RemoveOfflineCacheMin;
|
||||
|
||||
|
||||
public ClientManager()
|
||||
{
|
||||
//事件
|
||||
EventSystem.Instance.RegisterEvent<ServerType,Socket>(EEvent.OnSocketDisconnect, OnSocketDisconnect);
|
||||
}
|
||||
|
||||
#region 事件
|
||||
void OnSocketDisconnect(ServerType serverType, Socket socket)
|
||||
{
|
||||
if (serverType != ServerType.MainServer)
|
||||
return;
|
||||
|
||||
|
||||
RemoveClientBySocket(socket);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void Init(long ticktime, long RemoveOfflineCacheMin)
|
||||
{
|
||||
//换算成毫秒
|
||||
_RemoveOfflineCacheMin = RemoveOfflineCacheMin * 1000;
|
||||
_ClientCheckTimer = new System.Timers.Timer();
|
||||
_ClientCheckTimer.Interval = ticktime;
|
||||
_ClientCheckTimer.AutoReset = true;
|
||||
_ClientCheckTimer.Elapsed += new ElapsedEventHandler(ClientCheckClearOffline_Elapsed);
|
||||
_ClientCheckTimer.Enabled = true;
|
||||
}
|
||||
//public void Init(long ticktime, long RemoveOfflineCacheMin)
|
||||
//{
|
||||
// //换算成毫秒
|
||||
// _RemoveOfflineCacheMin = RemoveOfflineCacheMin * 1000;
|
||||
// _ClientCheckTimer = new System.Timers.Timer();
|
||||
// _ClientCheckTimer.Interval = ticktime;
|
||||
// _ClientCheckTimer.AutoReset = true;
|
||||
// _ClientCheckTimer.Elapsed += new ElapsedEventHandler(ClientCheckClearOffline_Elapsed);
|
||||
// _ClientCheckTimer.Enabled = true;
|
||||
//}
|
||||
|
||||
public long GetNextUID()
|
||||
{
|
||||
return ++TestUIDSeed;
|
||||
}
|
||||
|
||||
private void ClientCheckClearOffline_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
DateTime CheckDT = DateTime.Now.AddMinutes(-1 * _RemoveOfflineCacheMin);
|
||||
ClientInfo[] OfflineClientlist = ClientList.Where(w => w.IsOffline == true && w.LogOutDT < CheckDT).ToArray();
|
||||
//private void ClientCheckClearOffline_Elapsed(object sender, ElapsedEventArgs e)
|
||||
//{
|
||||
// DateTime CheckDT = DateTime.Now.AddMinutes(-1 * _RemoveOfflineCacheMin);
|
||||
// ClientInfo[] OfflineClientlist = ClientList.Where(w => w.IsOffline == true && w.LogOutDT < CheckDT).ToArray();
|
||||
|
||||
Console.WriteLine("开始清理离线过久的玩家的缓存");
|
||||
for (int i = 0; i < OfflineClientlist.Length; i++)
|
||||
{
|
||||
//to do 掉线处理
|
||||
RemoveClient(OfflineClientlist[i]);
|
||||
}
|
||||
GC.Collect();
|
||||
}
|
||||
// Console.WriteLine("开始清理离线过久的玩家的缓存");
|
||||
// for (int i = 0; i < OfflineClientlist.Length; i++)
|
||||
// {
|
||||
// //to do 掉线处理
|
||||
// RemoveClient(OfflineClientlist[i]);
|
||||
// }
|
||||
// GC.Collect();
|
||||
//}
|
||||
|
||||
|
||||
//通用处理
|
||||
@ -118,6 +130,8 @@ namespace ServerCore.Manager
|
||||
/// <param name="client"></param>
|
||||
public void RemoveClient(ClientInfo client)
|
||||
{
|
||||
EventSystem.Instance.PostEvent(EEvent.OnUserLeave, client.UID);
|
||||
|
||||
lock (ClientList)
|
||||
{
|
||||
if (_DictUIDClient.ContainsKey(client.UID))
|
||||
@ -150,22 +164,21 @@ namespace ServerCore.Manager
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置玩家离线
|
||||
/// </summary>
|
||||
/// <param name="sk"></param>
|
||||
public void SetClientOfflineForSocket(Socket sk)
|
||||
{
|
||||
if (!_DictSocketClient.ContainsKey(sk))
|
||||
return;
|
||||
///// <summary>
|
||||
///// 设置玩家离线
|
||||
///// </summary>
|
||||
///// <param name="sk"></param>
|
||||
//public void SetClientOfflineForSocket(Socket sk)
|
||||
//{
|
||||
// if (!_DictSocketClient.ContainsKey(sk))
|
||||
// return;
|
||||
// Console.WriteLine("标记玩家UID" + _DictSocketClient[sk].UID + "为离线");
|
||||
// _DictSocketClient[sk].IsOffline = true;
|
||||
// _DictSocketClient[sk].LogOutDT = DateTime.Now;
|
||||
// EventSystem.Instance.PostEvent(EEvent.OnUserLeave, _DictSocketClient[sk].UID);
|
||||
//}
|
||||
|
||||
Console.WriteLine("标记玩家UID" + _DictSocketClient[sk].UID + "为离线");
|
||||
_DictSocketClient[sk].IsOffline = true;
|
||||
_DictSocketClient[sk].LogOutDT = DateTime.Now;
|
||||
EventSystem.Instance.PostEvent(EEvent.OnUserLeave, _DictSocketClient[sk].UID);
|
||||
}
|
||||
|
||||
public void RemoveClientForSocket(Socket sk)
|
||||
public void RemoveClientBySocket(Socket sk)
|
||||
{
|
||||
if (!_DictSocketClient.ContainsKey(sk))
|
||||
return;
|
||||
|
@ -23,7 +23,9 @@ namespace ServerCore.Manager
|
||||
Status = LoginResultStatus.Ok,
|
||||
RegDate = "",
|
||||
LastLoginDate = "",
|
||||
Token = ""
|
||||
Token = "",
|
||||
UID = cinfo.UID,
|
||||
NickName= cinfo.NickName,
|
||||
});
|
||||
|
||||
ServerManager.g_ClientMgr.ClientSend(cinfo, (int)CommandID.CmdLogin, (int)ErrorCode.ErrorOk, respData);
|
||||
|
@ -10,7 +10,7 @@ namespace ServerCore.Manager
|
||||
public static LogManager g_Log;
|
||||
public static LoginManager g_Login;
|
||||
public static ChatManager g_Chat;
|
||||
public static P2PUserManager g_P2PMgr;
|
||||
public static UserManager g_UserMgr;
|
||||
public static TcpTunnelClientManager g_TcpTunnelMgr;
|
||||
public static IOCPNetWork g_SocketMgr;
|
||||
public static IOCPNetWork g_SocketTcpTunnelMgr;
|
||||
@ -18,16 +18,17 @@ namespace ServerCore.Manager
|
||||
public static void InitServer(int port, int tcptunnelport)
|
||||
{
|
||||
g_ClientMgr = new ClientManager();
|
||||
//g_ClientMgr.Init(10000, 10000);
|
||||
g_Log = new LogManager();
|
||||
g_Login = new LoginManager();
|
||||
g_Chat = new ChatManager();
|
||||
g_P2PMgr = new P2PUserManager();
|
||||
g_UserMgr = new UserManager();
|
||||
g_TcpTunnelMgr = new TcpTunnelClientManager();
|
||||
g_SocketMgr = new IOCPNetWork(1024, 1024);
|
||||
g_SocketMgr = new IOCPNetWork(1024, 1024,Common.Enum.ServerType.MainServer);
|
||||
g_SocketMgr.Init();
|
||||
Console.WriteLine("监听:" + port);
|
||||
g_SocketMgr.Start(new IPEndPoint(IPAddress.Any.Address, port));
|
||||
g_SocketTcpTunnelMgr = new IOCPNetWork(1024, 1024);
|
||||
g_SocketTcpTunnelMgr = new IOCPNetWork(1024, 1024, Common.Enum.ServerType.TcpTunnelServer);
|
||||
g_SocketTcpTunnelMgr.Init();
|
||||
g_SocketTcpTunnelMgr.Start(new IPEndPoint(IPAddress.Any.Address, tcptunnelport));
|
||||
Console.WriteLine("监听:" + tcptunnelport);
|
||||
|
@ -1,5 +1,6 @@
|
||||
using AxibugProtobuf;
|
||||
using ServerCore.Common;
|
||||
using ServerCore.Common.Enum;
|
||||
using ServerCore.Event;
|
||||
using ServerCore.NetWork;
|
||||
using System.Collections.Generic;
|
||||
@ -22,15 +23,29 @@ namespace ServerCore.Manager
|
||||
|
||||
public class TcpTunnelClientManager
|
||||
{
|
||||
private System.Timers.Timer _ClientCheckTimer;
|
||||
private long _RemoveOfflineCacheMin;
|
||||
public TcpTunnelClientManager()
|
||||
{
|
||||
//消息注册
|
||||
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTcptunnelHello, TcpTunnelHello);
|
||||
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTcptunnelDo, TcptunnelDo);
|
||||
//事件注册
|
||||
EventSystem.Instance.RegisterEvent<ServerType, Socket>(EEvent.OnSocketDisconnect, OnSocketDisconnect);
|
||||
}
|
||||
|
||||
private Dictionary<long, TCPTunnelClientInfo> _DictUID2Client = new Dictionary<long, TCPTunnelClientInfo>();
|
||||
private Dictionary<Socket, TCPTunnelClientInfo> _DictScoket2Client = new Dictionary<Socket, TCPTunnelClientInfo>();
|
||||
|
||||
#region 事件
|
||||
void OnSocketDisconnect(ServerType serverType, Socket socket)
|
||||
{
|
||||
if (serverType != ServerType.TcpTunnelServer)
|
||||
return;
|
||||
|
||||
RemoveClientBySocket(socket);
|
||||
}
|
||||
#endregion
|
||||
void AddClient(long UID,Socket _socket)
|
||||
{
|
||||
IPEndPoint ipEndPoint = (IPEndPoint)_socket.RemoteEndPoint;
|
||||
@ -44,6 +59,7 @@ namespace ServerCore.Manager
|
||||
_Socket = _socket
|
||||
};
|
||||
_DictScoket2Client[_socket] = cinfo;
|
||||
_DictUID2Client[UID] = cinfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -69,8 +85,7 @@ namespace ServerCore.Manager
|
||||
{
|
||||
if (_DictScoket2Client.ContainsKey(_socket))
|
||||
{
|
||||
_DictUID2Client.Remove(_DictScoket2Client[_socket].UID);
|
||||
_DictScoket2Client.Remove(_socket);
|
||||
RemoveClient(_DictScoket2Client[_socket].UID);
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,13 +113,15 @@ namespace ServerCore.Manager
|
||||
ServerManager.g_Log.Debug("收到TcpTunnel 打洞端口Hello");
|
||||
Protobuf_TcpTunnel_DoTunnel msg = ProtoBufHelper.DeSerizlize<Protobuf_TcpTunnel_DoTunnel>(reqData);
|
||||
TCPTunnelClientInfo Other = GetClient(msg.TargetUID);
|
||||
if (Other == null)
|
||||
|
||||
if (Other == null || msg.UID == msg.TargetUID)
|
||||
{
|
||||
Protobuf_TcpTunnel_DoTunnel_RESP respToErr = new Protobuf_TcpTunnel_DoTunnel_RESP();
|
||||
ClientSend(msg.UID, (int)CommandID.CmdTcptunnelDo, (int)ErrorCode.ErrorNotfand, ProtoBufHelper.Serizlize(respToErr));
|
||||
ClientSend(msg.UID, (int)CommandID.CmdTcptunnelDo, (int)ErrorCode.ErrorNotfind, ProtoBufHelper.Serizlize(respToErr));
|
||||
return;
|
||||
}
|
||||
|
||||
//发给自己
|
||||
TCPTunnelClientInfo mine = GetClient(msg.UID);
|
||||
Protobuf_TcpTunnel_DoTunnel_RESP respToMine = new Protobuf_TcpTunnel_DoTunnel_RESP()
|
||||
{
|
||||
@ -114,9 +131,9 @@ namespace ServerCore.Manager
|
||||
OtherPort= Other.Port,
|
||||
TargetUID = msg.TargetUID,
|
||||
};
|
||||
ClientSend(msg.UID, (int)CommandID.CmdTcptunnelHello, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(respToMine));
|
||||
|
||||
ClientSend(msg.UID, (int)CommandID.CmdTcptunnelDo, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(respToMine));
|
||||
|
||||
//发给对方
|
||||
Protobuf_TcpTunnel_DoTunnel_RESP respToOther = new Protobuf_TcpTunnel_DoTunnel_RESP()
|
||||
{
|
||||
MyIP = Other.IP,
|
||||
@ -125,11 +142,18 @@ namespace ServerCore.Manager
|
||||
OtherPort = mine.Port,
|
||||
TargetUID = msg.UID,
|
||||
};
|
||||
ClientSend(msg.TargetUID, (int)CommandID.CmdTcptunnelHello, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(respToOther));
|
||||
ClientSend(msg.TargetUID, (int)CommandID.CmdTcptunnelDo, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(respToOther));
|
||||
|
||||
//TODO 暂时服务器不断开,交由客户端收到后主动断开
|
||||
|
||||
//断开两边
|
||||
//mine._Socket.Close();
|
||||
//TCPTunnelClientInfo other = GetClient(msg.TargetUID);
|
||||
//other._Socket.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 错误
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="UID"></param>
|
||||
/// <param name="CMDID"></param>
|
||||
@ -142,5 +166,10 @@ namespace ServerCore.Manager
|
||||
ServerManager.g_SocketTcpTunnelMgr.SendToSocket(_DictUID2Client[UID]._Socket, CMDID, ERRCODE, data);
|
||||
}
|
||||
}
|
||||
|
||||
public int GetOnlineClientCount()
|
||||
{
|
||||
return _DictUID2Client.Count();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ using System.Timers;
|
||||
|
||||
namespace ServerCore.Manager
|
||||
{
|
||||
public class P2PUserManager
|
||||
public class UserManager
|
||||
{
|
||||
public P2PUserManager()
|
||||
public UserManager()
|
||||
{
|
||||
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdUserOnlinelist, RecvGetUserList);
|
||||
|
||||
@ -21,7 +21,7 @@ namespace ServerCore.Manager
|
||||
}
|
||||
|
||||
|
||||
#region
|
||||
#region 事件
|
||||
void OnUserJoin(long UID)
|
||||
{
|
||||
ServerManager.g_Log.Debug($"P2PUserManager->OnUserJoin UID->{UID}");
|
@ -1,15 +1,21 @@
|
||||
using AxibugProtobuf;
|
||||
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 IOCPNetWork(int numConnections, int receiveBufferSize)
|
||||
ServerType mServerType;
|
||||
public IOCPNetWork(int numConnections, int receiveBufferSize, ServerType serverType)
|
||||
: base(numConnections, receiveBufferSize)
|
||||
{
|
||||
mServerType = serverType;
|
||||
|
||||
m_clientCount = 0;
|
||||
m_maxConnectNum = numConnections;
|
||||
m_revBufferSize = receiveBufferSize;
|
||||
@ -38,22 +44,25 @@ namespace ServerCore.NetWork
|
||||
/// <param name="data">业务数据</param>
|
||||
public override void DataCallBack(AsyncUserToken token, int CMDID, byte[] data)
|
||||
{
|
||||
DataCallBackToOld(token.Socket, CMDID, data);
|
||||
//DataCallBackToOld(token.Socket, CMDID, data);
|
||||
ServerManager.g_Log.Debug("收到消息 CMDID =>" + CMDID + " 数据长度=>" + data.Length);
|
||||
//抛出网络数据
|
||||
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 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());
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 断开连接
|
||||
@ -61,10 +70,10 @@ namespace ServerCore.NetWork
|
||||
/// <param name="sk"></param>
|
||||
public override void OnClose(AsyncUserToken token)
|
||||
{
|
||||
Console.WriteLine("断开连接");
|
||||
ServerManager.g_Log.Debug($"断开连接,ServerType->{mServerType} | {((IPEndPoint)token.Socket.LocalEndPoint).Address}");
|
||||
//ServerManager.g_ClientMgr.SetClientOfflineForSocket(token.Socket);
|
||||
//TODO 要删除不同的
|
||||
ServerManager.g_ClientMgr.SetClientOfflineForSocket(token.Socket);
|
||||
s
|
||||
EventSystem.Instance.PostEvent(EEvent.OnSocketDisconnect, mServerType, token.Socket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,18 +65,19 @@ namespace ServerCore.NetWork
|
||||
public void PostNetMsgEvent(int cmd, Socket arg1, byte[] arg2)
|
||||
{
|
||||
List<Delegate> eventList = GetNetEventDicList(cmd);
|
||||
if (eventList != null)
|
||||
if (eventList == null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < eventList.Count; i++)
|
||||
{
|
||||
foreach (Delegate callback in eventList)
|
||||
Delegate callback = eventList[i];
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
((Action<Socket, byte[]>)callback)(arg1, arg2);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ServerManager.g_Log.Error(e.Message);
|
||||
}
|
||||
((Action<Socket, byte[]>)callback)(arg1, arg2);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ServerManager.g_Log.Error(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user