mirror of
https://github.com/MeowCraftMC/CrystalConnector
synced 2025-05-22 02:43:00 +00:00
* 🚧 WIP v2. Signed-off-by: 秋雨落 <i@rain.cx> * 🚧 WIP v2 * 2. Signed-off-by: 秋雨落 <i@rain.cx> * ✨ It works? Signed-off-by: 秋雨落 <i@rain.cx> * ✨ Publish to nexus. Signed-off-by: 秋雨落 <i@rain.cx> --------- Signed-off-by: 秋雨落 <i@rain.cx>
43 lines
871 B
C#
43 lines
871 B
C#
using CrystalConnector.Protocol.Messages;
|
|
using Google.Protobuf;
|
|
|
|
namespace CrystalConnector.Protocol.Packets.C2S;
|
|
|
|
public class PublishPacket : IPacket
|
|
{
|
|
public NamespacedName Channel { get; set; }
|
|
public string Payload { get; set; }
|
|
|
|
public PublishPacket(NamespacedName channel, string payload)
|
|
{
|
|
Channel = channel;
|
|
Payload = payload;
|
|
}
|
|
|
|
public PublishPacket(byte[] bytes)
|
|
{
|
|
Read(bytes);
|
|
}
|
|
|
|
public PublishPacket()
|
|
{
|
|
}
|
|
|
|
public void Read(byte[] bytes)
|
|
{
|
|
var message = Publish.Parser.ParseFrom(bytes);
|
|
Channel = message.Channel;
|
|
Payload = message.Payload;
|
|
}
|
|
|
|
public byte[] Write()
|
|
{
|
|
var message = new Publish
|
|
{
|
|
Channel = Channel,
|
|
Payload = Payload
|
|
};
|
|
|
|
return message.ToByteArray();
|
|
}
|
|
} |