Exemplo n.º 1
0
        public void Write()
        {
            if (_writer.BaseStream.Length == 0)
            {
                _writer.Write(Id);
                if (Target != null)
                {
                    _writer.Write7BitLongValue((ulong)Value.Length);

                    _writer.Write(Value);

                    _writer.Write7BitValue((uint)CookieComputing.Nonce.Length);

                    _writer.Write(CookieComputing.Nonce);

                    _writer.Write7BitValue((uint)CookieComputing.InitiatorNonce.Length);

                    _writer.Write(CookieComputing.InitiatorNonce);
                }
                else
                {
                    _writer.Write7BitLongValue((ulong)CookieComputing.Nonce.Length);

                    _writer.Write(CookieComputing.Nonce);
                }

                _writer.Write((byte)0x58);
            }
        }
Exemplo n.º 2
0
 public void Flush(H2NBinaryWriter writer, ulong stage, byte flags, bool header, N2HBinaryReader reader, ushort size)
 {
     Debug.WriteLine("sent:{0} stage {1}", Id, stage);
     if (_stageAck == 0 && header)
     {
         flags |= MESSAGE_HEADER;
     }
     if (size == 0)
     {
         flags |= MESSAGE_ABANDONMENT;
     }
     if (Closed && _messages.Count == 1)
     {
         flags |= MESSAGE_END;
     }
     writer.Write(flags);
     if (header)
     {
         writer.Write7BitLongValue(Id);
         writer.Write7BitLongValue(stage);
         writer.Write7BitLongValue(stage - _stageAck);
         if (_stageAck == 0)
         {
             writer.WriteString8(Signature);
             if (FlowId > 0)
             {
                 writer.Write((byte)(1 + H2NBinaryWriter.Get7BitValueSize(FlowId)));
                 writer.Write((byte)0x0a);
                 writer.Write7BitLongValue(FlowId);
             }
             writer.Write((byte)0);
         }
     }
     if (size > 0)
     {
         reader.BaseStream.CopyPartTo(writer.BaseStream, size);
     }
 }