26 lines
		
	
	
		
			781 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			781 B
		
	
	
	
		
			C#
		
	
	
	
	
	
using System.IO;
 | 
						|
using System.Threading.Tasks;
 | 
						|
 | 
						|
namespace Passer.RoboidControl {
 | 
						|
 | 
						|
    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<bool> Receive(Stream dataStream, Participant client, byte packetSize) {
 | 
						|
            byte[] buffer = await Receive(dataStream, packetSize);
 | 
						|
            TextMsg msg = new TextMsg(buffer);
 | 
						|
 | 
						|
            client.messageQueue.Enqueue(msg);
 | 
						|
            return true;
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
} |