private final void copy(WebSocketFrame copy, ByteBuffer payload) { fin = copy.fin; rsv1 = copy.rsv1; rsv2 = copy.rsv2; rsv3 = copy.rsv3; opcode = copy.opcode; type = copy.type; masked = copy.masked; mask = null; if (copy.mask != null) { mask = new byte[copy.mask.length]; System.arraycopy(copy.mask,0,mask,0,mask.length); } continuationIndex = copy.continuationIndex; continuation = copy.continuation; setPayload(payload); }
public WebSocketFrame setPayload(String str) { setPayload(BufferUtil.toBuffer(str,StringUtil.__UTF8_CHARSET)); return this; }
@Override public WebSocketFrame setPayload(ByteBuffer buf) { if (buf != null && buf.remaining() > MAX_CONTROL_PAYLOAD) { throw new ProtocolException("Control Payloads can not exceed " + MAX_CONTROL_PAYLOAD + " bytes in length."); } return super.setPayload(buf); }
public static WebSocketFrame text(String msg) { return new WebSocketFrame(OpCode.TEXT).setPayload(msg); }
public WebSocketFrame setPayload(String str) { setPayload(BufferUtil.toBuffer(str,StringUtil.__UTF8_CHARSET)); return this; }
public static WebSocketFrame binary(byte buf[]) { return new WebSocketFrame(OpCode.BINARY).setPayload(buf); }
public static WebSocketFrame text(String msg) { return new WebSocketFrame(OpCode.TEXT).setPayload(msg); }
public static WebSocketFrame binary(byte buf[]) { return new WebSocketFrame(OpCode.BINARY).setPayload(buf); }
public WebSocketFrame asFrame() { WebSocketFrame frame = new WebSocketFrame(OpCode.CLOSE); frame.setFin(true); frame.setPayload(asByteBuffer()); return frame; }
public WebSocketFrame asFrame() { WebSocketFrame frame = new WebSocketFrame(OpCode.CLOSE); frame.setFin(true); frame.setPayload(asByteBuffer()); return frame; }
@Override public void sendPing(ByteBuffer applicationData) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("sendPing with {}",BufferUtil.toDetailString(applicationData)); } WebSocketFrame frame = WebSocketFrame.ping().setPayload(applicationData); blockingWrite(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 void sendPong(ByteBuffer applicationData) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("sendPong with {}",BufferUtil.toDetailString(applicationData)); } WebSocketFrame frame = WebSocketFrame.pong().setPayload(applicationData); blockingWrite(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 void sendPing(ByteBuffer applicationData) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("sendPing with {}",BufferUtil.toDetailString(applicationData)); } WebSocketFrame frame = WebSocketFrame.ping().setPayload(applicationData); blockingWrite(frame); }
@Override public void sendPong(ByteBuffer applicationData) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("sendPong with {}",BufferUtil.toDetailString(applicationData)); } WebSocketFrame frame = WebSocketFrame.pong().setPayload(applicationData); blockingWrite(frame); }
@Override public void sendPartialBytes(ByteBuffer fragment, boolean isLast) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("sendPartialBytes({}, {})",BufferUtil.toDetailString(fragment),isLast); } WebSocketFrame frame = WebSocketFrame.binary().setPayload(fragment).setFin(isLast); blockingWrite(frame); }
@Override public void sendPartialBytes(ByteBuffer fragment, boolean isLast) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("sendPartialBytes({}, {})",BufferUtil.toDetailString(fragment),isLast); } WebSocketFrame frame = WebSocketFrame.binary().setPayload(fragment).setFin(isLast); blockingWrite(frame); }
/** * Blocking write of bytes. */ @Override public void sendBytes(ByteBuffer data) throws IOException { connection.getIOState().assertOutputOpen(); if (LOG.isDebugEnabled()) { LOG.debug("sendBytes with {}",BufferUtil.toDetailString(data)); } WebSocketFrame frame = WebSocketFrame.binary().setPayload(data); blockingWrite(frame); }
/** * Blocking write of bytes. */ @Override public void sendBytes(ByteBuffer data) throws IOException { connection.getIOState().assertOutputOpen(); if (LOG.isDebugEnabled()) { LOG.debug("sendBytes with {}",BufferUtil.toDetailString(data)); } WebSocketFrame frame = WebSocketFrame.binary().setPayload(data); blockingWrite(frame); }