finished the protocol
This commit is contained in:
parent
84d9bd0ef0
commit
661c217a73
4 changed files with 121 additions and 20 deletions
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
|
@ -54,16 +52,17 @@ public class Message
|
|||
|
||||
public byte[] Bytes()
|
||||
{
|
||||
// initialize a list
|
||||
List<byte> msg = [];
|
||||
// 0..4
|
||||
// 0..4 - message id
|
||||
msg.AddRange(BitConverter.GetBytes(Id));
|
||||
// 4..12
|
||||
// 4..12 - sender's phone number
|
||||
msg.AddRange(Utils.NumberToBytes(Sender));
|
||||
// 12
|
||||
// 12 - is this message an acknowledgement or a normal message
|
||||
msg.Add((byte)(IsAck ? 1 : 0));
|
||||
// 13..(len - 32)
|
||||
// 13.. the message itself (should be empty for an acknowledgement)
|
||||
msg.AddRange(Encoding.UTF8.GetBytes(Content));
|
||||
|
||||
// Turn into array, prepending the version byte
|
||||
return [0, .. msg];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue