static protected UTF8Buffer readUTF(DataByteArrayInputStream is) throws ProtocolException { int size = is.readUnsignedShort(); Buffer buffer = is.readBuffer(size); if (buffer == null || buffer.length != size) { throw new ProtocolException("Invalid message encoding"); } return buffer.utf8(); }
public SUBACK decode(MQTTFrame frame) throws ProtocolException { assert(frame.buffers.length == 1); DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]); messageId = is.readShort(); grantedQos = is.readBuffer(is.available()).toByteArray(); return this; }
public PUBLISH decode(MQTTFrame frame) throws ProtocolException { assert(frame.buffers.length == 1); header(frame.header()); DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]); topicName = MessageSupport.readUTF(is); QoS qos = qos(); if(qos != QoS.AT_MOST_ONCE) { messageId = is.readShort(); } payload = is.readBuffer(is.available()); if( payload == null ) { payload = new Buffer(0); } return this; }
static protected UTF8Buffer readUTF(DataByteArrayInputStream is) throws ProtocolException { int size = is.readUnsignedShort(); Buffer buffer = is.readBuffer(size); if (buffer == null || buffer.length != size) { throw new ProtocolException("Invalid message encoding"); } return buffer.utf8(); }
protected UTF8Buffer looseUnmarshalString(DataByteArrayInputStream dataIn) throws IOException { if (dataIn.readBoolean()) { int size = dataIn.readShort(); return dataIn.readBuffer(size).utf8(); } else { return null; } }
protected UTF8Buffer looseUnmarshalString(DataByteArrayInputStream dataIn) throws IOException { if (dataIn.readBoolean()) { int size = dataIn.readShort(); return dataIn.readBuffer(size).utf8(); } else { return null; } }
public SUBACK decode(MQTTFrame frame) throws ProtocolException { assert(frame.buffers.length == 1); DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]); messageId = is.readShort(); grantedQos = is.readBuffer(is.available()).toByteArray(); return this; }
@SuppressWarnings("deprecation") protected UTF8Buffer tightUnmarshalString(DataByteArrayInputStream dataIn, BooleanStream bs) throws IOException { if (bs.readBoolean()) { boolean ascii = bs.readBoolean(); // ignored for now. int size = dataIn.readShort(); if( size== 0 ) { return new UTF8Buffer(""); } else { Buffer buffer = dataIn.readBuffer(size); return buffer.utf8(); } } else { return null; } }
@SuppressWarnings("deprecation") protected UTF8Buffer tightUnmarshalString(DataByteArrayInputStream dataIn, BooleanStream bs) throws IOException { if (bs.readBoolean()) { boolean ascii = bs.readBoolean(); // ignored for now. int size = dataIn.readShort(); if( size== 0 ) { return new UTF8Buffer(""); } else { Buffer buffer = dataIn.readBuffer(size); return buffer.utf8(); } } else { return null; } }
public PUBLISH decode(MQTTFrame frame) throws ProtocolException { assert(frame.buffers.length == 1); header(frame.header()); DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]); topicName = MessageSupport.readUTF(is); QoS qos = qos(); if(qos != QoS.AT_MOST_ONCE) { messageId = is.readShort(); } payload = is.readBuffer(is.available()); if( payload == null ) { payload = new Buffer(0); } return this; }