Ejemplo n.º 1
0
 public void Write(Stream stream)
 {
     using (STUNBinaryWriter binary = new STUNBinaryWriter(stream))
     {
         Write(binary);
     }
 }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 public abstract void WriteBody(STUNBinaryWriter binary);