Further improvements

This commit is contained in:
Pascal Serrarens 2024-12-06 17:38:17 +01:00
parent a48ae12fc2
commit f35d60369d
2 changed files with 9 additions and 8 deletions

View File

@ -3,9 +3,9 @@ using Passer;
public class LowLevelMessages {
public static void SendSpherical(byte[] buffer, ref uint ix, Spherical v) {
SendFloat16(buffer, ref ix, new float16(v.distance));
SendAngle8(buffer, ref ix, v.horizontal);
SendAngle8(buffer, ref ix, v.vertical);
SendFloat16(buffer, ref ix, new float16(v.distance));
}
public static Spherical ReceiveSpherical(byte[] data, ref uint ix) {

View File

@ -231,6 +231,7 @@ namespace Passer.Control {
}
#endregion Investigate
#region Thing
public class ThingMsg : IMessage {
@ -288,13 +289,13 @@ namespace Passer.Control {
public NameMsg(byte[] data) : base(data) { }
public override byte[] Serialize() {
byte[] data = new byte[length + this.name.Length];
data[0] = NameMsg.Id;
data[1] = this.thingId;
data[2] = (byte)this.name.Length;
byte[] buffer = new byte[length + this.name.Length];
buffer[0] = NameMsg.Id;
buffer[1] = this.thingId;
buffer[2] = (byte)this.name.Length;
for (int ix = 0; ix < this.name.Length; ix++)
data[3 + ix] = (byte)this.name[ix];
return data;
buffer[3 + ix] = (byte)this.name[ix];
return buffer;
}
public override void Deserialize(byte[] data) {
uint ix = 0;
@ -304,7 +305,7 @@ namespace Passer.Control {
}
public static bool Send(Client client, byte thingId, string name) {
NameMsg msg = new NameMsg(thingId, name);
NameMsg msg = new(thingId, name);
return SendMsg(client, msg);
}
public static async Task<bool> Receive(Stream dataStream, Client client, byte packetSize) {