HaoYueTunnel/ClientCore/Manager/P2PChat.cs

29 lines
905 B
C#
Raw Normal View History

2023-06-15 15:45:58 +08:00
using AxibugProtobuf;
using ClientCore.Common;
using ClientCore.Event;
using ClientCore.Network;
namespace ClientCore.Manager
{
public class P2PChat
{
2023-06-15 16:48:37 +08:00
public P2PChat()
2023-06-15 15:45:58 +08:00
{
2023-06-15 16:48:37 +08:00
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTcpP2PChat, RecvChatMsg);
2023-06-15 15:45:58 +08:00
}
2023-06-15 16:48:37 +08:00
public void SendChatMsg(long UID, string ChatMsg)
2023-06-15 15:45:58 +08:00
{
Protobuf_TcpP2P_Chat msg = new Protobuf_TcpP2P_Chat()
{
ChatMsg = ChatMsg,
};
2023-06-16 18:04:08 +08:00
App.clientMgr.SendToTargetSocket(UID, (int)CommandID.CmdTcpP2PChat,(int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(msg));
2023-06-15 16:48:37 +08:00
}
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);
2023-06-15 15:45:58 +08:00
}
}
}