public async Task SendPacket(IStreamable packet, IPEndPoint recipient) { using (MemoryStream memStream = new MemoryStream(new byte[152])) using (BinaryWriter writer = new BinaryWriter(memStream)) { packet.WriteToStream(writer); var bytePacket = memStream.ToArray(); await _client.SendAsync(bytePacket, bytePacket.Length, recipient); } }
public static void Write(IStreamable data, Stream stream) { data.WriteToStream(new BinaryWriter(stream)); }