Exemplo n.º 1
0
        protected override void readMessage(MessageStream input, int msgLength)
        {
            short msb = input.readByte();
            byte  lsb = input.readByte();
            int   id  = msb << 8;

            id += lsb;
            setMessageId(id);

            //            setMessageId((short)(input.readByte() >> 8 + input.readByte()));
        }
Exemplo n.º 2
0
 protected override void readMessage(MessageStream input, int msgLength)
 {
     base.readMessage(input, msgLength);
     while (input.Size() > 0)
     {
         String topic = ReadStringFromStream(input);
         //System.out.println("Topic : " + topic);
         topics.Add(topic);
         topicQoSs.Add((QoS)input.readByte());
     }
 }
Exemplo n.º 3
0
        protected override void readMessage(MessageStream input, int msgLength)
        {
            base.readMessage(input, msgLength);
            int pos = 2;

            while (pos < msgLength)
            {
                QoS qos = (QoS)(input.readByte());
                addQoS(qos);
                pos++;
            }
        }
Exemplo n.º 4
0
        protected override void readMessage(MessageStream input, int msgLength)
        {
            ReadStringFromStream(input);   //PROTOCOL_ID
            input.readByte();              // PROTOCOL_VERSION
            byte flags = input.readByte(); //flags

            keepAlive = (short)ReadUshortFromStream(input);
            clientId  = ReadStringFromStream(input);

            if (((flags & 0x04) != 0))
            {
                willTopic = ReadStringFromStream(input);
                will      = ReadStringFromStream(input);
            }

            username = ((flags & 0x80) == 0) ? null : ReadStringFromStream(input);
            password = ((flags & 0x40) == 0) ? null : ReadStringFromStream(input);

            retainWill = ((flags & 0x20) > 0);
            willQoS    = (QoS)(Convert.ToUInt16(flags & 0x18) >> 3);
        }
Exemplo n.º 5
0
        protected override void readMessage(MessageStream input, int msgLength)
        {
            if (msgLength != 2)
            {
                //            throw new IllegalStateException("Message Length must be 2 for CONNACK. Current value: " + msgLength);
            }
            // Ignore first byte
            input.readByte();
            int result = input.readByte();

            switch (result)
            {
            case 0:
                status = ConnectionStatus.ACCEPTED;
                break;

            case 1:
                status = ConnectionStatus.UNACCEPTABLE_PROTOCOL_VERSION;
                break;

            case 2:
                status = ConnectionStatus.IDENTIFIER_REJECTED;
                break;

            case 3:
                status = ConnectionStatus.SERVER_UNAVAILABLE;
                break;

            case 4:
                status = ConnectionStatus.BAD_USERNAME_OR_PASSWORD;
                break;

            case 5:
                status = ConnectionStatus.NOT_AUTHORIZED;
                break;

            default:
                throw new NotSupportedException("Unsupported CONNACK code: " + result);
            }
        }
Exemplo n.º 6
0
 protected ushort ReadUshortFromStream(MessageStream input)
 {
     return((ushort)((input.readByte() << 8) + input.readByte()));
 }