/// <summary> /// Returns the message as byte array. /// </summary> /// <returns></returns> public override void ToByteArray(ByteArrayBuilder byteArrayBuilder) { byteArrayBuilder .Add(this.ControlEndpoint.ToByteArray()) .Add(this.DataEndpoint.ToByteArray()) .Add(this.Data.ToByteArray()); }
public void Send(byte [] buffer, bool noEncode) { if (buffer == null) { return; } mutex.WaitOne(); if (result == null) { result = new ByteArrayBuilder(); } if (!noEncode) { Encode(buffer); } result.Add(buffer); mutex.ReleaseMutex(); }
/// <summary> /// Toes the byte array. /// </summary> /// <param name="byteArrayBuilder">The byte array builder.</param> public override void ToByteArray(ByteArrayBuilder byteArrayBuilder) { byteArrayBuilder.AddByte(this.CommunicationChannel).AddByte((byte)this.State); if (this.State != ErrorCode.NoError) { return; } byteArrayBuilder.Add(this.HostProtocolAddressInfo.ToByteArray()).AddByte(2) // Length .AddByte((byte)this.ConnectionType); }
private static byte[] FormatMessage(ref LowLevelRequestMessage message) { var bytes = new ByteArrayBuilder() .Add(Bytes.SYN) .Add(message.Command.acronym); if (!message.Parameters.Any()) { message = message.With(parameters: new[] { string.Empty }); } foreach (var parameter in message.Parameters) { bytes .Add(parameter.Length.ToString("000")) .Add(parameter); } bytes.Add(Bytes.ETB); var crc = Crc16.Compute(bytes.Skip(1)); bytes.Add((byte)(crc / 256), (byte)(crc % 256)); return(bytes.ToArray()); }
public override void BuildAsByteArray(ByteArrayBuilder builder) { base.BuildAsByteArray(builder); builder.Add(IsGameStarted); builder.Add(DeckSize); builder.Add(PlayerIndex); builder.Add(Reverse); builder.Add(Top); builder.Add(Winner); builder.AddList(Players); builder.AddList(PlayerHandSizes); builder.Add(Cards); }
public override void BuildAsByteArray(ByteArrayBuilder builder) { base.BuildAsByteArray(builder); builder.Add(CardIndex); builder.Add(Card); }
public override void ToByteArray(ByteArrayBuilder byteArrayBuilder) { byteArrayBuilder.Add(Cemi.ToByteArray()); }
public override void BuildAsByteArray(ByteArrayBuilder builder) { base.BuildAsByteArray(builder); builder.Add(Username); }
public override void ToByteArray(ByteArrayBuilder byteArrayBuilder) { byteArrayBuilder.Add(Endpoint.ToByteArray()); }
public override void BuildAsByteArray(ByteArrayBuilder builder) { base.BuildAsByteArray(builder); builder.Add(Message); }
public override void BuildAsByteArray(ByteArrayBuilder builder) { builder.Add(Type); }