Пример #1
0
        /// <summary>
        /// Remove message decoder
        /// </summary>
        /// <exception cref="StyxErrorMessageException">Throws StyxErrorMessageException when Rerror received</exception>
        /// <exception cref="Exception">Throws Exception when unsupported message received</exception>
        public new void SetBinary(byte[] data)
        {
            base.SetBinary(data);
            if (this.Type == MessageType.Rremove)
                return; // ok, Rremove have no extra fields, so we can just return

            if (this.Type == MessageType.Rerror)
            {
                StyxErrorMessage error = new StyxErrorMessage();
                error.SetBinary(data);
                throw new StyxErrorMessageException(error);
                return;
            }
            throw new Exception("Incorrect message type");
        }
Пример #2
0
 /// <summary>
 /// message decoder
 /// </summary>
 /// <param name="data"></param>
 public new void SetBinary(byte[] data)
 {
     base.SetBinary(data);
     if (this.Type == MessageType.Rread)
     {
         SetRBinary(data);
         return;
     }
     if (this.Type == MessageType.Tread)
     {
         SetTBinary(data);
         return;
     }
     if (this.Type == MessageType.Rerror)
     {
         StyxErrorMessage error = new StyxErrorMessage();
         error.SetBinary(data);
         throw new StyxErrorMessageException(error);
         return;
     }
     throw new Exception("Incorrect message type");
 }
Пример #3
0
        /// <summary>
        /// message decoder
        /// </summary>
        /// <param name="data"></param>
        public new void SetBinary(byte[] data)
        {
            base.SetBinary(data);
            if (this.Type == MessageType.Rerror)
            {
                StyxErrorMessage error = new StyxErrorMessage();
                error.SetBinary(data);
                throw new StyxErrorMessageException(error);
                return;
            }
            if ((this.Type != MessageType.Tversion) && (this.Type != MessageType.Rversion))
                throw new Exception("Incorrect message type");
            int pos = (int)base.GetBinarySize();
            this.max_packet_size = BitConverter.ToUInt32(data, pos);
            pos += sizeof(uint);
            ushort protocol_size = BitConverter.ToUInt16(data, pos);
            pos += sizeof(ushort);

            protocol_version = Encoding.UTF8.GetString(data, pos, protocol_size);
        }