private void blockingWrite(WebSocketFrame frame) throws IOException { Future<Void> fut = sendAsyncFrame(frame); try { fut.get(); // block till done } catch (ExecutionException e) { throw new IOException("Failed to write bytes",e.getCause()); } catch (InterruptedException e) { throw new IOException("Failed to write bytes",e); } }
private void blockingWrite(WebSocketFrame frame) throws IOException { Future<Void> fut = sendAsyncFrame(frame); try { fut.get(); // block till done } catch (ExecutionException e) { throw new IOException("Failed to write bytes",e.getCause()); } catch (InterruptedException e) { throw new IOException("Failed to write bytes",e); } }
@Override public Future<Void> sendBytesByFuture(ByteBuffer data) { if (LOG.isDebugEnabled()) { LOG.debug("sendBytesByFuture with {}",BufferUtil.toDetailString(data)); } WebSocketFrame frame = WebSocketFrame.binary().setPayload(data); return sendAsyncFrame(frame); }
@Override public void sendPong(ByteBuffer applicationData) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("sendPong with {}", BufferUtil.toDetailString(applicationData)); } sendAsyncFrame(new PongFrame().setPayload(applicationData)); }
@Override public Future<Void> sendStringByFuture(String text) { WebSocketFrame frame = WebSocketFrame.text(text); if (LOG.isDebugEnabled()) { LOG.debug("sendStringByFuture with {}",BufferUtil.toDetailString(frame.getPayload())); } return sendAsyncFrame(frame); } }
@Override public Future<Void> sendBytesByFuture(ByteBuffer data) { if (LOG.isDebugEnabled()) { LOG.debug("sendBytesByFuture with {}",BufferUtil.toDetailString(data)); } WebSocketFrame frame = WebSocketFrame.binary().setPayload(data); return sendAsyncFrame(frame); }
@Override public Future<Void> sendStringByFuture(String text) { WebSocketFrame frame = WebSocketFrame.text(text); if (LOG.isDebugEnabled()) { LOG.debug("sendStringByFuture with {}",BufferUtil.toDetailString(frame.getPayload())); } return sendAsyncFrame(frame); } }
@Override public void sendPing(ByteBuffer applicationData) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("sendPing with {}", BufferUtil.toDetailString(applicationData)); } sendAsyncFrame(new PingFrame().setPayload(applicationData)); }
@Override public Future<Void> sendBytesByFuture(ByteBuffer data) { lockMsg(MsgType.ASYNC); try { if (LOG.isDebugEnabled()) { LOG.debug("sendBytesByFuture with {}", BufferUtil.toDetailString(data)); } return sendAsyncFrame(new BinaryFrame().setPayload(data)); } finally { unlockMsg(MsgType.ASYNC); } }
@Override public Future<Void> sendStringByFuture(String text) { lockMsg(MsgType.ASYNC); try { TextFrame frame = new TextFrame().setPayload(text); if (LOG.isDebugEnabled()) { LOG.debug("sendStringByFuture with {}", BufferUtil.toDetailString(frame.getPayload())); } return sendAsyncFrame(frame); } finally { unlockMsg(MsgType.ASYNC); } }