HaoYueTunnel/ClientCore/Manager/AppChat.cs

31 lines
850 B
C#
Raw Normal View History

2023-05-25 13:24:51 +08:00
using AxibugProtobuf;
2023-05-25 18:30:22 +08:00
using ClientCore.Common;
using ClientCore.Event;
using ClientCore.Network;
2023-05-25 13:24:51 +08:00
2023-05-25 18:30:22 +08:00
namespace ClientCore.Manager
2023-05-25 13:24:51 +08:00
{
public class AppChat
{
2023-05-25 18:30:22 +08:00
public AppChat()
{
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdChatmsg, RecvChatMsg);
}
2023-05-25 13:24:51 +08:00
public void SendChatMsg(string ChatMsg)
{
Protobuf_ChatMsg msg = new Protobuf_ChatMsg()
{
ChatMsg = ChatMsg,
};
2023-06-15 15:45:58 +08:00
App.networkMain.SendToServer((int)CommandID.CmdChatmsg, ProtoBufHelper.Serizlize(msg));
2023-05-25 13:24:51 +08:00
}
public void RecvChatMsg(byte[] reqData)
{
2023-05-25 18:30:22 +08:00
Protobuf_ChatMsg_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_ChatMsg_RESP>(reqData);
EventSystem.Instance.PostEvent(EEvent.OnChatMsg, msg.NickName, msg.ChatMsg);
2023-05-25 13:24:51 +08:00
}
}
}