using System.IO; using System.Threading.Tasks; namespace Passer.Control.Core { public class TextMsg : IMessage { public TextMsg(byte[] buffer) : base(buffer) {} public const byte Id = 0xB0; public string text = ""; public override void Deserialize(byte[] buffer) { uint ix = 0; uint strlen = buffer[ix++]; this.text = System.Text.Encoding.UTF8.GetString(buffer, (int)ix, (int)strlen); } public static async Task Receive(Stream dataStream, Participant client, byte packetSize) { byte[] buffer = await Receive(dataStream, packetSize); TextMsg msg = new TextMsg(buffer); client.messageQueue.Enqueue(msg); return true; } } }