public CloseMessage(final ByteBuffer buffer) { if(buffer.remaining() >= 2) { code = (buffer.get() & 0XFF) << 8 | (buffer.get() & 0xFF); reason = new UTF8Output(buffer).extract(); } else { code = NORMAL_CLOSURE; reason = ""; } }
@Override public void handleEvent(final StreamSourceChannel channel) { PooledByteBuffer resource = bufferPool.allocate(); ByteBuffer buffer = resource.getBuffer(); try { int r = 0; do { r = channel.read(buffer); if (r == 0) { return; } else if (r == -1) { stringDone(string.extract()); IoUtils.safeClose(channel); } else { buffer.flip(); string.write(buffer); } } while (r > 0); } catch (IOException e) { error(e); } finally { resource.close(); } }
public void write(ByteBuffer... bytes) { for (ByteBuffer buf : bytes) { while (buf.hasRemaining()) { write(buf.get()); } } }
/** * Gets the buffered data and clears the buffered text message. If this is not called on a UTF8 * character boundary there may be partial code point data that is still buffered. * * @return The data */ public String getData() { return data.extract(); }
public UTF8Output(ByteBuffer... payload) { stringBuilder = new StringBuilder((int) Buffers.remaining(payload)); write(payload); }
/** * Gets the buffered data and clears the buffered text message. If this is not called on a UTF8 * character boundary there may be partial code point data that is still buffered. * * @return The data */ public String getData() { return data.extract(); }
public void setup(final StreamSourceChannel channel) { PooledByteBuffer resource = bufferPool.allocate(); ByteBuffer buffer = resource.getBuffer(); try { int r = 0; do { r = channel.read(buffer); if (r == 0) { channel.getReadSetter().set(this); channel.resumeReads(); } else if (r == -1) { stringDone(string.extract()); IoUtils.safeClose(channel); } else { buffer.flip(); string.write(buffer); } } while (r > 0); } catch (IOException e) { error(e); } finally { resource.close(); } }
public void readBlocking(StreamSourceFrameChannel channel) throws IOException { PooledByteBuffer pooled = channel.getWebSocketChannel().getBufferPool().allocate(); final ByteBuffer buffer = pooled.getBuffer(); try { for (; ; ) { int res = channel.read(buffer); if (res == -1) { buffer.flip(); data.write(buffer); this.complete = true; return; } else if (res == 0) { channel.awaitReadable(); } checkMaxSize(channel, res); if (!buffer.hasRemaining()) { buffer.flip(); data.write(buffer); buffer.compact(); if (!bufferFullMessage) { //if we are not reading the full message we return return; } } } } finally { pooled.close(); } }
public CloseMessage(final ByteBuffer buffer) { if(buffer.remaining() >= 2) { code = (buffer.get() & 0XFF) << 8 | (buffer.get() & 0xFF); reason = new UTF8Output(buffer).extract(); } else { code = NORMAL_CLOSURE; reason = ""; } }
/** * Gets the buffered data and clears the buffered text message. If this is not called on a UTF8 * character boundary there may be partial code point data that is still buffered. * * @return The data */ public String getData() { return data.extract(); }
@Override public void handleEvent(final StreamSourceChannel channel) { PooledByteBuffer resource = bufferPool.allocate(); ByteBuffer buffer = resource.getBuffer(); try { int r = 0; do { r = channel.read(buffer); if (r == 0) { return; } else if (r == -1) { stringDone(string.extract()); IoUtils.safeClose(channel); } else { buffer.flip(); string.write(buffer); } } while (r > 0); } catch (IOException e) { error(e); } finally { resource.close(); } }
checkMaxSize(channel, res); buffer.flip(); data.write(buffer); complete = true; callback.complete(channel.getWebSocketChannel(), BufferedTextMessage.this); buffer.flip(); if (buffer.hasRemaining()) { data.write(buffer); if (!bufferFullMessage) { callback.complete(channel.getWebSocketChannel(), BufferedTextMessage.this); data.write(buffer); buffer.clear(); if (!bufferFullMessage) {
public CloseMessage(final ByteBuffer buffer) { if(buffer.remaining() >= 2) { code = (buffer.get() & 0XFF) << 8 | (buffer.get() & 0xFF); reason = new UTF8Output(buffer).extract(); } else { code = NORMAL_CLOSURE; reason = ""; } }
@Override public void handleEvent(final StreamSourceChannel channel) { PooledByteBuffer resource = bufferPool.allocate(); ByteBuffer buffer = resource.getBuffer(); try { int r = 0; do { r = channel.read(buffer); if (r == 0) { return; } else if (r == -1) { stringDone(string.extract()); IoUtils.safeClose(channel); } else { buffer.flip(); string.write(buffer); } } while (r > 0); } catch (IOException e) { error(e); } finally { resource.close(); } }
this.complete = true; buffer.flip(); data.write(buffer); callback.complete(channel.getWebSocketChannel(), this); return; buffer.flip(); if (buffer.hasRemaining()) { data.write(buffer); if (!bufferFullMessage) { callback.complete(channel.getWebSocketChannel(), this); if (!buffer.hasRemaining()) { buffer.flip(); data.write(buffer); buffer.clear(); if (!bufferFullMessage) {
public void setup(final StreamSourceChannel channel) { PooledByteBuffer resource = bufferPool.allocate(); ByteBuffer buffer = resource.getBuffer(); try { int r = 0; do { r = channel.read(buffer); if (r == 0) { channel.getReadSetter().set(this); channel.resumeReads(); } else if (r == -1) { stringDone(string.extract()); IoUtils.safeClose(channel); } else { buffer.flip(); string.write(buffer); } } while (r > 0); } catch (IOException e) { error(e); } finally { resource.close(); } }
public void write(ByteBuffer... bytes) { for (ByteBuffer buf : bytes) { while (buf.hasRemaining()) { write(buf.get()); } } }
public void setup(final StreamSourceChannel channel) { PooledByteBuffer resource = bufferPool.allocate(); ByteBuffer buffer = resource.getBuffer(); try { int r = 0; do { r = channel.read(buffer); if (r == 0) { channel.getReadSetter().set(this); channel.resumeReads(); } else if (r == -1) { stringDone(string.extract()); IoUtils.safeClose(channel); } else { buffer.flip(); string.write(buffer); } } while (r > 0); } catch (IOException e) { error(e); } finally { resource.close(); } }
public void write(ByteBuffer... bytes) { for (ByteBuffer buf : bytes) { while (buf.hasRemaining()) { write(buf.get()); } } }
public UTF8Output(ByteBuffer... payload) { stringBuilder = new StringBuilder((int) Buffers.remaining(payload)); write(payload); }