public SUBSCRIBE decode(MQTTFrame frame) throws ProtocolException { assert(frame.buffers.length == 1); header(frame.header()); DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]); QoS qos = qos(); if(qos != QoS.AT_MOST_ONCE) { messageId = is.readShort(); } ArrayList<Topic> list = new ArrayList<Topic>(); while(is.available() > 0) { Topic topic = new Topic(MessageSupport.readUTF(is), QoS.values()[is.readByte()]); list.add(topic); } topics = list.toArray(new Topic[list.size()]); return this; }
public CONNACK decode(MQTTFrame frame) throws ProtocolException { assert(frame.buffers.length == 1); DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]); is.skip(1); byte c = is.readByte(); if( c >= Code.values().length ) { throw new ProtocolException("Invalid CONNACK encoding"); } code = Code.values()[c]; return this; }
version = is.readByte() & 0xFF; if( version < 4 ) { throw new ProtocolException("Invalid CONNECT frame: protocol name/version mismatch"); version = is.readByte() & 0xFF; if( version != 3 ) { throw new ProtocolException("Invalid CONNECT frame: protocol name/version mismatch"); byte flags = is.readByte(); boolean username_flag = (flags & 0x80) > 0; boolean password_flag = (flags & 0x40) > 0;
@Override protected byte readByte() throws IOException { return DataByteArrayInputStream.this.readByte(); }
@Override protected byte readByte() throws IOException { return DataByteArrayInputStream.this.readByte(); }
@Override protected byte readByte() throws IOException { return DataByteArrayInputStream.this.readByte(); }
@Override public void parse(DataByteArrayInputStream data, int readSize) throws IOException { while (readSize-- > 0) { byte b = data.readByte(); // skip repeating nulls if (b == 0) { continue; } header = b; currentParser = initializeVariableLengthParser(); if (readSize > 0) { currentParser.parse(data, readSize); } return; } }
@Override public void parse(DataByteArrayInputStream data, int readSize) throws IOException { while (readSize-- > 0) { byte b = data.readByte(); // skip repeating nulls if (b == 0) { continue; } header = b; currentParser = initializeVariableLengthParser(); if (readSize > 0) { currentParser.parse(data, readSize); } return; } }
@Override public void parse(DataByteArrayInputStream data, int readSize) throws IOException { while (readSize-- > 0) { byte b = data.readByte(); // skip repeating nulls if (b == 0) { continue; } header = b; currentParser = initializeVariableLengthParser(); if (readSize > 0) { currentParser.parse(data, readSize); } return; } }
@Override public void parse(DataByteArrayInputStream data, int readSize) throws IOException { while (readSize-- > 0) { byte b = data.readByte(); // skip repeating nulls if (b == 0) { continue; } header = b; currentParser = initializeVariableLengthParser(); if (readSize > 0) { currentParser.parse(data, readSize); } return; } }
@Override public void parse(DataByteArrayInputStream data, int readSize) throws IOException { while (readSize-- > 0) { byte b = data.readByte(); // skip repeating nulls if (b == 0) { continue; } header = b; currentParser = initializeVariableLengthParser(); if (readSize > 0) { currentParser.parse(data, readSize); } return; } }
public DataStructure looseUnmarshalNestedObject(DataByteArrayInputStream dis) throws IOException { if (dis.readBoolean()) { byte dataType = dis.readByte(); DataStreamMarshaller dsm = (DataStreamMarshaller) dataMarshallers[dataType & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + dataType); } DataStructure data = dsm.createObject(); dsm.looseUnmarshal(this, data, dis); return data; } else { return null; } }
public DataStructure looseUnmarshalNestedObject(DataByteArrayInputStream dis) throws IOException { if (dis.readBoolean()) { byte dataType = dis.readByte(); DataStreamMarshaller dsm = (DataStreamMarshaller) dataMarshallers[dataType & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + dataType); } DataStructure data = dsm.createObject(); dsm.looseUnmarshal(this, data, dis); return data; } else { return null; } }
public SUBSCRIBE decode(MQTTFrame frame) throws ProtocolException { assert(frame.buffers.length == 1); header(frame.header()); DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]); QoS qos = qos(); if(qos != QoS.AT_MOST_ONCE) { messageId = is.readShort(); } ArrayList<Topic> list = new ArrayList<Topic>(); while(is.available() > 0) { Topic topic = new Topic(MessageSupport.readUTF(is), QoS.values()[is.readByte()]); list.add(topic); } topics = list.toArray(new Topic[list.size()]); return this; }
public CONNACK decode(MQTTFrame frame) throws ProtocolException { assert(frame.buffers.length == 1); DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]); is.skip(1); byte c = is.readByte(); if( c >= Code.values().length ) { throw new ProtocolException("Invalid CONNACK encoding"); } code = Code.values()[c]; return this; }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataByteArrayInputStream dataIn, BooleanStream bs) throws IOException { super.tightUnmarshal(wireFormat, o, dataIn, bs); TransactionInfo info = (TransactionInfo)o; info.setConnectionId((ConnectionId)tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setTransactionId((TransactionId)tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setType(dataIn.readByte()); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataByteArrayInputStream dataIn) throws IOException { super.looseUnmarshal(wireFormat, o, dataIn); TransactionInfo info = (TransactionInfo)o; info.setConnectionId((ConnectionId)looseUnmarsalCachedObject(wireFormat, dataIn)); info.setTransactionId((TransactionId)looseUnmarsalCachedObject(wireFormat, dataIn)); info.setType(dataIn.readByte()); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataByteArrayInputStream dataIn, BooleanStream bs) throws IOException { super.tightUnmarshal(wireFormat, o, dataIn, bs); TransactionInfo info = (TransactionInfo)o; info.setConnectionId((ConnectionId)tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setTransactionId((TransactionId)tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setType(dataIn.readByte()); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataByteArrayInputStream dataIn) throws IOException { super.looseUnmarshal(wireFormat, o, dataIn); TransactionInfo info = (TransactionInfo)o; info.setConnectionId((ConnectionId)looseUnmarsalCachedObject(wireFormat, dataIn)); info.setTransactionId((TransactionId)looseUnmarsalCachedObject(wireFormat, dataIn)); info.setType(dataIn.readByte()); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataByteArrayInputStream dataIn, BooleanStream bs) throws IOException { super.tightUnmarshal(wireFormat, o, dataIn, bs); MessageAck info = (MessageAck)o; info.setDestination((ActiveMQDestination)tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setTransactionId((TransactionId)tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setConsumerId((ConsumerId)tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setAckType(dataIn.readByte()); info.setFirstMessageId((MessageId)tightUnmarsalNestedObject(wireFormat, dataIn, bs)); info.setLastMessageId((MessageId)tightUnmarsalNestedObject(wireFormat, dataIn, bs)); info.setMessageCount(dataIn.readInt()); }