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.
@ -10,6 +10,7 @@ EventSystem.Instance.RegisterEvent(EEvent.TcpTunnelHelloResp, OnTcpTunnelHelloRe
|
||||
EventSystem.Instance.RegisterEvent<long>(EEvent.UserJoin, OnUserJoin);
|
||||
EventSystem.Instance.RegisterEvent<long>(EEvent.UserLeave, OnUserLeave);
|
||||
EventSystem.Instance.RegisterEvent<string, string>(EEvent.OnChatMsg, OnChatMsg);
|
||||
EventSystem.Instance.RegisterEvent<long, string>(EEvent.OnP2PChatMsg, OnP2PChatMsg);
|
||||
|
||||
while (true)
|
||||
{
|
||||
@ -57,6 +58,14 @@ while (true)
|
||||
}
|
||||
App.chat.SendChatMsg(CmdArr[1]);
|
||||
break;
|
||||
case "tusay":
|
||||
if (CmdArr.Length < 3)
|
||||
{
|
||||
Console.WriteLine("缺省参数");
|
||||
return;
|
||||
}
|
||||
App.p2pChat.SendChatMsg(Convert.ToInt64(CmdArr[1]), CmdArr[2]);
|
||||
break;
|
||||
case "ulist":
|
||||
{
|
||||
UserInfo[] ulist = App.userMgr.GetUserInfo();
|
||||
@ -100,3 +109,8 @@ void OnChatMsg(string str1, string str2)
|
||||
{
|
||||
Console.WriteLine($"[Chat]{str1}:{str2}");
|
||||
}
|
||||
|
||||
void OnP2PChatMsg(long uid, string str2)
|
||||
{
|
||||
Console.WriteLine($"[P2PChatMsg]{uid}:{str2}");
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ namespace ClientCore
|
||||
public static LogManager log;
|
||||
public static ClientManager clientMgr;
|
||||
public static P2PTcp p2ptcp;
|
||||
public static P2PChat p2pChat;
|
||||
public static NetworkHelper networkMain;
|
||||
public static NetworkHelper networkTcp2S;
|
||||
public static AppLogin login;
|
||||
@ -32,6 +33,7 @@ namespace ClientCore
|
||||
clientMgr = new ClientManager();
|
||||
clientMgr.SetIpData(IP, port, tcptunnelport);
|
||||
p2ptcp = new P2PTcp();
|
||||
p2pChat = new P2PChat();
|
||||
networkMain = new NetworkHelper(Enum.ServerType.MainServer);
|
||||
networkMain.Init(IP, port);
|
||||
//networkTcp2S = new NetworkHelper(Enum.ServerType.TcpTunnelServer);
|
||||
|
@ -13,6 +13,7 @@ namespace ClientCore.Event
|
||||
UserJoin,
|
||||
UserLeave,
|
||||
OnChatMsg,
|
||||
OnP2PChatMsg,
|
||||
|
||||
//打洞流程
|
||||
TcpTunnelHelloResp,
|
||||
|
@ -7,17 +7,22 @@ namespace ClientCore.Manager
|
||||
{
|
||||
public class P2PChat
|
||||
{
|
||||
public P2PChat()
|
||||
public P2PChat()
|
||||
{
|
||||
//NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdChatmsg, RecvChatMsg);
|
||||
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTcpP2PChat, RecvChatMsg);
|
||||
}
|
||||
public void SendChatMsg(long UID,string ChatMsg)
|
||||
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));
|
||||
App.clientMgr.SendToTargetSocket(UID, (int)CommandID.CmdTcpP2PChat, ProtoBufHelper.Serizlize(msg));
|
||||
}
|
||||
public void RecvChatMsg(long uid, byte[] reqData)
|
||||
{
|
||||
Protobuf_TcpP2P_Chat msg = ProtoBufHelper.DeSerizlize<Protobuf_TcpP2P_Chat>(reqData);
|
||||
EventSystem.Instance.PostEvent(EEvent.OnP2PChatMsg, uid, msg.ChatMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,11 @@
|
||||
InterRegNetMsgEvent(cmd, callback);
|
||||
}
|
||||
|
||||
public void RegNetMsgEvent(int cmd, Action<long,byte[]> callback)
|
||||
{
|
||||
InterRegNetMsgEvent(cmd, callback);
|
||||
}
|
||||
|
||||
private void InterRegNetMsgEvent(int cmd, Delegate callback)
|
||||
{
|
||||
if (netEventDic.ContainsKey(cmd))
|
||||
@ -42,6 +47,11 @@
|
||||
InterUnregisterCMD(evt, tempDelegate);
|
||||
}
|
||||
|
||||
public void UnregisterCMD(int evt, Action<long, byte[]> callback)
|
||||
{
|
||||
Delegate tempDelegate = callback;
|
||||
InterUnregisterCMD(evt, tempDelegate);
|
||||
}
|
||||
private void InterUnregisterCMD(int cmd, Delegate callback)
|
||||
{
|
||||
if (netEventDic.ContainsKey(cmd))
|
||||
@ -53,6 +63,25 @@
|
||||
#endregion
|
||||
|
||||
#region PostEvent
|
||||
public void PostNetMsgEvent(int cmd, long uid, byte[] arg)
|
||||
{
|
||||
List<Delegate> eventList = GetNetEventDicList(cmd);
|
||||
if (eventList != null)
|
||||
{
|
||||
foreach (Delegate callback in eventList)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Action<long,byte[]>)callback)(uid,arg);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
App.log.Error(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PostNetMsgEvent(int cmd, byte[] arg)
|
||||
{
|
||||
List<Delegate> eventList = GetNetEventDicList(cmd);
|
||||
|
@ -66,7 +66,14 @@ namespace ClientCore.Network
|
||||
try
|
||||
{
|
||||
//抛出网络数据
|
||||
NetMsg.Instance.PostNetMsgEvent(CMDID, data);
|
||||
if (mServerType == ServerType.TcpP2PTarget)
|
||||
{
|
||||
NetMsg.Instance.PostNetMsgEvent(CMDID, mUID,data);
|
||||
}
|
||||
else
|
||||
{
|
||||
NetMsg.Instance.PostNetMsgEvent(CMDID, data);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Binary file not shown.
@ -0,0 +1,17 @@
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\bin\Debug\net7.0\ClientCore.deps.json
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\bin\Debug\net7.0\ClientCore.dll
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\bin\Debug\net7.0\ClientCore.pdb
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\bin\Debug\net7.0\Google.Protobuf.dll
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\bin\Debug\net7.0\HaoYueNet.ClientNetwork.dll
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\bin\Debug\net7.0\Protobuf.dll
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\bin\Debug\net7.0\Protobuf.pdb
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\obj\Debug\net7.0\ClientCore.csproj.AssemblyReference.cache
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\obj\Debug\net7.0\ClientCore.GeneratedMSBuildEditorConfig.editorconfig
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\obj\Debug\net7.0\ClientCore.AssemblyInfoInputs.cache
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\obj\Debug\net7.0\ClientCore.AssemblyInfo.cs
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\obj\Debug\net7.0\ClientCore.csproj.CoreCompileInputs.cache
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\obj\Debug\net7.0\ClientCore.csproj.CopyComplete
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\obj\Debug\net7.0\ClientCore.dll
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\obj\Debug\net7.0\refint\ClientCore.dll
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\obj\Debug\net7.0\ClientCore.pdb
|
||||
F:\Sin365\HaoYueTunnel\ClientCore\obj\Debug\net7.0\ref\ClientCore.dll
|
Binary file not shown.
@ -0,0 +1,14 @@
|
||||
F:\Sin365\HaoYueTunnel\Protobuf\bin\Debug\net7.0\Protobuf.deps.json
|
||||
F:\Sin365\HaoYueTunnel\Protobuf\bin\Debug\net7.0\Protobuf.dll
|
||||
F:\Sin365\HaoYueTunnel\Protobuf\bin\Debug\net7.0\Protobuf.pdb
|
||||
F:\Sin365\HaoYueTunnel\Protobuf\bin\Debug\net7.0\Google.Protobuf.dll
|
||||
F:\Sin365\HaoYueTunnel\Protobuf\obj\Debug\net7.0\Protobuf.csproj.AssemblyReference.cache
|
||||
F:\Sin365\HaoYueTunnel\Protobuf\obj\Debug\net7.0\Protobuf.GeneratedMSBuildEditorConfig.editorconfig
|
||||
F:\Sin365\HaoYueTunnel\Protobuf\obj\Debug\net7.0\Protobuf.AssemblyInfoInputs.cache
|
||||
F:\Sin365\HaoYueTunnel\Protobuf\obj\Debug\net7.0\Protobuf.AssemblyInfo.cs
|
||||
F:\Sin365\HaoYueTunnel\Protobuf\obj\Debug\net7.0\Protobuf.csproj.CoreCompileInputs.cache
|
||||
F:\Sin365\HaoYueTunnel\Protobuf\obj\Debug\net7.0\Protobuf.csproj.CopyComplete
|
||||
F:\Sin365\HaoYueTunnel\Protobuf\obj\Debug\net7.0\Protobuf.dll
|
||||
F:\Sin365\HaoYueTunnel\Protobuf\obj\Debug\net7.0\refint\Protobuf.dll
|
||||
F:\Sin365\HaoYueTunnel\Protobuf\obj\Debug\net7.0\Protobuf.pdb
|
||||
F:\Sin365\HaoYueTunnel\Protobuf\obj\Debug\net7.0\ref\Protobuf.dll
|
Binary file not shown.
@ -0,0 +1,22 @@
|
||||
F:\Sin365\HaoYueTunnel\Server\bin\Debug\net7.0\Server.exe
|
||||
F:\Sin365\HaoYueTunnel\Server\bin\Debug\net7.0\Server.deps.json
|
||||
F:\Sin365\HaoYueTunnel\Server\bin\Debug\net7.0\Server.runtimeconfig.json
|
||||
F:\Sin365\HaoYueTunnel\Server\bin\Debug\net7.0\Server.dll
|
||||
F:\Sin365\HaoYueTunnel\Server\bin\Debug\net7.0\Server.pdb
|
||||
F:\Sin365\HaoYueTunnel\Server\bin\Debug\net7.0\Protobuf.dll
|
||||
F:\Sin365\HaoYueTunnel\Server\bin\Debug\net7.0\ServerCore.dll
|
||||
F:\Sin365\HaoYueTunnel\Server\bin\Debug\net7.0\HaoYueNet.ServerNetwork.dll
|
||||
F:\Sin365\HaoYueTunnel\Server\bin\Debug\net7.0\Google.Protobuf.dll
|
||||
F:\Sin365\HaoYueTunnel\Server\bin\Debug\net7.0\ServerCore.pdb
|
||||
F:\Sin365\HaoYueTunnel\Server\bin\Debug\net7.0\Protobuf.pdb
|
||||
F:\Sin365\HaoYueTunnel\Server\obj\Debug\net7.0\Server.csproj.AssemblyReference.cache
|
||||
F:\Sin365\HaoYueTunnel\Server\obj\Debug\net7.0\Server.GeneratedMSBuildEditorConfig.editorconfig
|
||||
F:\Sin365\HaoYueTunnel\Server\obj\Debug\net7.0\Server.AssemblyInfoInputs.cache
|
||||
F:\Sin365\HaoYueTunnel\Server\obj\Debug\net7.0\Server.AssemblyInfo.cs
|
||||
F:\Sin365\HaoYueTunnel\Server\obj\Debug\net7.0\Server.csproj.CoreCompileInputs.cache
|
||||
F:\Sin365\HaoYueTunnel\Server\obj\Debug\net7.0\Server.csproj.CopyComplete
|
||||
F:\Sin365\HaoYueTunnel\Server\obj\Debug\net7.0\Server.dll
|
||||
F:\Sin365\HaoYueTunnel\Server\obj\Debug\net7.0\refint\Server.dll
|
||||
F:\Sin365\HaoYueTunnel\Server\obj\Debug\net7.0\Server.pdb
|
||||
F:\Sin365\HaoYueTunnel\Server\obj\Debug\net7.0\Server.genruntimeconfig.cache
|
||||
F:\Sin365\HaoYueTunnel\Server\obj\Debug\net7.0\ref\Server.dll
|
Binary file not shown.
@ -0,0 +1,17 @@
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\bin\Debug\net7.0\ServerCore.deps.json
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\bin\Debug\net7.0\ServerCore.dll
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\bin\Debug\net7.0\ServerCore.pdb
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\bin\Debug\net7.0\Google.Protobuf.dll
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\bin\Debug\net7.0\HaoYueNet.ServerNetwork.dll
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\bin\Debug\net7.0\Protobuf.dll
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\bin\Debug\net7.0\Protobuf.pdb
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\obj\Debug\net7.0\ServerCore.csproj.AssemblyReference.cache
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\obj\Debug\net7.0\ServerCore.GeneratedMSBuildEditorConfig.editorconfig
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\obj\Debug\net7.0\ServerCore.AssemblyInfoInputs.cache
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\obj\Debug\net7.0\ServerCore.AssemblyInfo.cs
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\obj\Debug\net7.0\ServerCore.csproj.CoreCompileInputs.cache
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\obj\Debug\net7.0\ServerCore.csproj.CopyComplete
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\obj\Debug\net7.0\ServerCore.dll
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\obj\Debug\net7.0\refint\ServerCore.dll
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\obj\Debug\net7.0\ServerCore.pdb
|
||||
F:\Sin365\HaoYueTunnel\ServerCore\obj\Debug\net7.0\ref\ServerCore.dll
|
Loading…
Reference in New Issue
Block a user