namespace RoboidControl {
///
/// A participant messages notifies other participants of its presence
///
/// When received by another participant, it can be followed by a NetworkIdMsg
/// to announce that participant to this client such that it can join privately
public class ParticipantMsg : IMessage {
///
/// The message ID
///
public const byte Id = 0xA0;
///
/// The length of the message
///
public const byte length = 2;
///
/// The network ID known by the participant
///
public byte networkId;
///
/// Create a new message for sending
///
/// The network ID known by the participant
public ParticipantMsg(byte networkId) {
this.networkId = networkId;
}
///
/// Create a message for receiving
///
/// The byte array to parse
public ParticipantMsg(byte[] buffer) {
this.networkId = buffer[1];
}
///
/// Serialize the message into a byte array
///
/// The buffer to serialize into
/// The length of the message in the buffer
public override byte Serialize(ref byte[] buffer) {
if (buffer.Length < ParticipantMsg.length)
return 0;
byte ix = 0;
buffer[ix++] = ParticipantMsg.Id;
buffer[ix++] = networkId;
return ParticipantMsg.length;
}
}
}