static private String hex(SocketAddress address) { if( address instanceof InetSocketAddress ) { InetSocketAddress isa = (InetSocketAddress)address; return HexSupport.toHexFromBuffer(new Buffer(isa.getAddress().getAddress()))+Integer.toHexString(isa.getPort()); } return ""; }
public MQTTFrame apply() throws IOException { int limit = readBuffer.position(); if ((limit - readStart) < length) { readEnd = limit; return null; } else { Buffer body = new Buffer(readBuffer.array(), readStart, length); readEnd = readStart = readStart + length; nextDecodeAction = readHeader; return new MQTTFrame(body).header(header); } } };
public void publish(final String topic, final byte[] payload, final QoS qos, final boolean retain) throws Exception { publish(utf8(topic), new Buffer(payload), qos, retain); }
public void publish(String topic, byte[] payload, QoS qos, boolean retain, Callback<Void> cb) { publish(utf8(topic), new Buffer(payload), qos, retain, cb); }
public Future<Void> publish(final String topic, final byte[] payload, final QoS qos, final boolean retain) { return publish(utf8(topic), new Buffer(payload), qos, retain); }
raf.seek(0); raf.readFully(data); main.body = new Buffer(data); } finally { raf.close();
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; }
@Override protected Buffer createBuffer(byte[] data) { return new Buffer(data); } }
final public Buffer trimFront() { byte data[] = this.data; int offset = this.offset; int end = offset+this.length; int pos = offset; while ((pos < end) && (data[pos] <= ' ')) { pos++; } return (pos == offset) ? this : new Buffer(data, pos, (length-(pos-offset))); }
public final Buffer slice(int low, int high) { int sz; if (high < 0) { sz = length + high; } else { sz = high - low; } if (sz < 0) { sz = 0; } return new Buffer(data, (offset + low), sz); }
final public Buffer trimFront() { byte data[] = this.data; int offset = this.offset; int end = offset+this.length; int pos = offset; while ((pos < end) && (data[pos] <= ' ')) { pos++; } return (pos == offset) ? this : new Buffer(data, pos, (length-(pos-offset))); }
final public Buffer deepCopy() { byte t[] = new byte[length]; System.arraycopy(data, offset, t, 0, length); return new Buffer(t); }
public Buffer decode(DataInput dataIn) throws IOException { byte[] data = new byte[size]; dataIn.readFully(data); return new Buffer(data); }
final public Buffer compact() { if (length != data.length) { return new Buffer(toByteArray()); } return this; }
public void readHeader() { buffer = paged.slice(SliceType.READ, page, 1); Buffer m = new Buffer(magic.length); buffer.get(m.data); if( !magic.equals(m) ) { throw new IOPagingException("Invalid extent read request. The requested page was not an extent: "+page); } IntBuffer ib = buffer.asIntBuffer(); length = ib.get(); next = ib.get(); }
public void storeContent() throws JMSException { try { if( text == null ) { setContent(new Buffer(0)); } else { setContent(new Buffer(text.getBytes("UTF-8"))); } getHeaderMap().put(TRANSFORMATION, getMsgType().buffer); } catch (UnsupportedEncodingException e) { throw StompJmsExceptionSupport.create(e.getMessage(), e); } }
public AmqpHeader readAmqpHeader() throws Exception { clientSocket.setSoTimeout((int) RECEIVE_TIMEOUT); InputStream is = clientSocket.getInputStream(); byte[] header = new byte[8]; int read = is.read(header); if (read == header.length) { return new AmqpHeader(new Buffer(header)); } else { return null; } } }
private void setBytesHeader(AsciiBuffer key, byte[] value) { if(value==null) { getHeaderMap().remove(key); } else { getHeaderMap().put(key, new Buffer(value).deepCopy().ascii()); } }
protected Buffer looseUnmarshalBuffer(DataByteArrayInputStream dataIn) throws IOException { Buffer rc = null; if (dataIn.readBoolean()) { int size = dataIn.readInt(); byte[] t = new byte[size]; dataIn.readFully(t); rc = new Buffer(t, 0, size); } return rc; } }
/** * Converts a Binary value to a long assuming that the contained value is * stored in Big Endian encoding. * * @param value the Binary object whose payload is converted to a long. * @return a long value constructed from the bytes of the Binary instance. */ public static long toLong(Binary value) { Buffer buffer = new Buffer(value.getArray(), value.getArrayOffset(), value.getLength()); return buffer.bigEndianEditor().readLong(); }