protected AckBase decode(MQTTFrame frame) throws ProtocolException { assert(frame.buffers.length == 1); DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]); messageId = is.readShort(); return this; }
public UNSUBSCRIBE decode(MQTTFrame frame) throws ProtocolException { assert(frame.buffers.length == 1); header(frame.header()); DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]); messageId = is.readShort(); ArrayList<UTF8Buffer> list = new ArrayList<UTF8Buffer>(); while(is.available() > 0) { list.add(MessageSupport.readUTF(is)); } topics = list.toArray(new UTF8Buffer[list.size()]); return this; }
public PUBREL decode(MQTTFrame frame) throws ProtocolException { assert(frame.buffers.length == 1); header(frame.header()); DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]); messageId = is.readShort(); return this; }
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 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; }
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; }
public CONNECT decode(MQTTFrame frame) throws ProtocolException { assert(frame.buffers.length == 1); DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]);
protected void processBuffer(ByteBuffer buffer, int readSize) throws Exception { buffer.flip(); DataByteArrayInputStream dis = new DataByteArrayInputStream(buffer.array()); codec.parse(dis, readSize); receiveCounter += readSize; // clear the buffer buffer.clear(); }
@Override protected void processCommand(ByteBuffer plain) throws Exception { byte[] fill = new byte[plain.remaining()]; plain.get(fill); DataByteArrayInputStream dis = new DataByteArrayInputStream(fill); codec.parse(dis, fill.length); }
public static Properties stringToProperties(String str) throws IOException { Properties result = new Properties(); if (str != null && str.length() > 0) { DataByteArrayInputStream dataIn = new DataByteArrayInputStream(str.getBytes()); result.load(dataIn); dataIn.close(); } return result; }
protected void processBuffer(ByteBuffer buffer, int readSize) throws Exception { buffer.flip(); DataByteArrayInputStream dis = new DataByteArrayInputStream(buffer.array()); codec.parse(dis, readSize); receiveCounter += readSize; // clear the buffer buffer.clear(); }
public static Properties stringToProperties(String str) throws IOException { Properties result = new Properties(); if (str != null && str.length() > 0) { DataByteArrayInputStream dataIn = new DataByteArrayInputStream(str.getBytes()); result.load(dataIn); dataIn.close(); } return result; }
protected void processBuffer(ByteBuffer buffer, int readSize) throws Exception { buffer.flip(); DataByteArrayInputStream dis = new DataByteArrayInputStream(buffer.array()); codec.parse(dis, readSize); receiveCounter += readSize; // clear the buffer buffer.clear(); }
@Override protected void processCommand(ByteBuffer plain) throws Exception { byte[] fill = new byte[plain.remaining()]; plain.get(fill); DataByteArrayInputStream dis = new DataByteArrayInputStream(fill); codec.parse(dis, fill.length); }
public UNSUBSCRIBE decode(MQTTFrame frame) throws ProtocolException { assert(frame.buffers.length == 1); header(frame.header()); DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]); messageId = is.readShort(); ArrayList<UTF8Buffer> list = new ArrayList<UTF8Buffer>(); while(is.available() > 0) { list.add(MessageSupport.readUTF(is)); } topics = list.toArray(new UTF8Buffer[list.size()]); return this; }
public PUBREL decode(MQTTFrame frame) throws ProtocolException { assert(frame.buffers.length == 1); header(frame.header()); DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]); messageId = is.readShort(); return this; }
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; }
private void process(Buffer event) { if (!isStopped() && !isStopping()) { try { int length = event.length(); org.fusesource.hawtbuf.DataByteArrayInputStream dataIn = new org.fusesource.hawtbuf.DataByteArrayInputStream(event.getBytes()); codec.parse(dataIn, length); } catch (Throwable e) { transport.handleException(e); } } }
private void process(Buffer event) { if (!isStopped() && !isStopping()) { try { int length = event.length(); org.fusesource.hawtbuf.DataByteArrayInputStream dataIn = new org.fusesource.hawtbuf.DataByteArrayInputStream(event.getBytes()); codec.parse(dataIn, length); } catch (Throwable e) { transport.handleException(e); } } }