public void Write(Stream stream) { using (STUNBinaryWriter binary = new STUNBinaryWriter(stream)) { Write(binary); } }
public virtual void Write(STUNBinaryWriter binary) { binary.Write((ushort)GetAttribute(GetType())); var lengthPos = binary.BaseStream.Position; binary.Write((ushort)0); var bodyPos = binary.BaseStream.Position; WriteBody(binary); var length = binary.BaseStream.Position - bodyPos; var endPos = binary.BaseStream.Position; binary.BaseStream.Position = lengthPos; binary.Write((ushort)length); binary.BaseStream.Position = endPos; }
public void Write(STUNBinaryWriter binary) { binary.Write((ushort)MessageType); binary.Write((ushort)0); binary.Write(TransactionID); long length = 0; foreach (var attribute in Attributes) { var startPos = binary.BaseStream.Position; attribute.Write(binary); length += binary.BaseStream.Position - startPos; } binary.BaseStream.Position = 2; binary.Write((ushort)length); }
public abstract void WriteBody(STUNBinaryWriter binary);