HaoYueNet/Simple/ClientCore/Manager/AppChat.cs

31 lines
851 B
C#
Raw Normal View History

2023-05-25 13:46:54 +08:00
using AxibugProtobuf;
2023-05-25 18:04:01 +08:00
using ClientCore.Common;
using ClientCore.Event;
2023-05-25 13:46:54 +08:00
using ClientCore.Network;
namespace ClientCore.Manager
{
public class AppChat
{
2023-05-25 18:04:01 +08:00
public AppChat()
{
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdChatmsg, RecvChatMsg);
}
2023-05-25 13:46:54 +08:00
public void SendChatMsg(string ChatMsg)
{
Protobuf_ChatMsg msg = new Protobuf_ChatMsg()
{
ChatMsg = ChatMsg,
};
2023-05-25 18:04:01 +08:00
App.networkHelper.SendToServer((int)CommandID.CmdChatmsg, ProtoBufHelper.Serizlize(msg));
2023-05-25 13:46:54 +08:00
}
public void RecvChatMsg(byte[] reqData)
{
2023-05-25 18:04:01 +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:46:54 +08:00
}
}
}