Merge commit '355dd5c1c519cf07cfb6b9f9200f7f7311e68f20' into V2
This commit is contained in:
commit
394dc220ca
39
Messages.cs
39
Messages.cs
@ -237,26 +237,39 @@ namespace Passer.Control {
|
||||
public class ThingMsg : IMessage {
|
||||
public const byte length = 5;
|
||||
public const byte Id = 0x80;
|
||||
public byte objectId;
|
||||
public byte objectType;
|
||||
public byte networkId;
|
||||
public byte thingId;
|
||||
public byte thingType;
|
||||
public byte parentId;
|
||||
|
||||
public ThingMsg(byte networkId, byte thingId, byte thingType, byte parentId) {
|
||||
this.networkId = networkId;
|
||||
this.thingId = thingId;
|
||||
this.thingType = thingType;
|
||||
this.parentId = parentId;
|
||||
}
|
||||
public ThingMsg(byte[] data) : base(data) { }
|
||||
public override void Deserialize(byte[] data) {
|
||||
|
||||
public override byte[] Serialize() {
|
||||
byte[] data = new byte[ThingMsg.length];
|
||||
data[0] = ThingMsg.Id;
|
||||
data[1] = this.networkId;
|
||||
data[2] = this.thingId;
|
||||
data[3] = this.thingType;
|
||||
data[4] = this.parentId;
|
||||
return data;
|
||||
}
|
||||
public override void Deserialize(byte[] data) {
|
||||
uint ix = 0;
|
||||
objectId = data[ix++];
|
||||
objectType = data[ix++];
|
||||
parentId = data[ix];
|
||||
this.networkId = data[ix++];
|
||||
this.thingId = data[ix++];
|
||||
this.thingType = data[ix++];
|
||||
this.parentId = data[ix];
|
||||
}
|
||||
|
||||
public static bool Send(Client client, byte thingId, byte thingType, byte parentId) {
|
||||
byte[] data = new byte[ThingMsg.length];
|
||||
data[0] = ThingMsg.Id;
|
||||
data[1] = client.networkId;
|
||||
data[2] = thingId;
|
||||
data[3] = thingType;
|
||||
data[4] = parentId;
|
||||
return SendMsg(client, data);
|
||||
ThingMsg msg = new(client.networkId, thingId, thingType, parentId);
|
||||
return SendMsg(client, msg);
|
||||
}
|
||||
public static async Task<bool> Receive(Stream dataStream, Client client, byte packetSize) {
|
||||
if (packetSize != length)
|
||||
|
Loading…
x
Reference in New Issue
Block a user