private void blockingWrite(WebSocketFrame frame) throws IOException { try(WriteBlocker b=blocker.acquireWriteBlocker()) { uncheckedSendFrame(frame, b); b.block(); } }
public WebSocketFrame asFrame() { WebSocketFrame frame = new WebSocketFrame(OpCode.CLOSE); frame.setFin(true); frame.setPayload(asByteBuffer()); return frame; }
/** * Aborts the active session abruptly. * @param statusCode the status code * @param reason the raw reason code */ public void abort(int statusCode, String reason) { close(new CloseInfo(statusCode, reason), new DisconnectCallback()); }
@Override public void flush() throws IOException { lockMsg(MsgType.ASYNC); try (WriteBlocker b = blocker.acquireWriteBlocker()) { uncheckedSendFrame(FrameFlusher.FLUSH_FRAME, b); b.block(); } finally { unlockMsg(MsgType.ASYNC); } }
@Override public void setMask(WebSocketFrame frame) { frame.setMask(mask); } }
/** * Harsh disconnect */ @Override public void disconnect() { connection.disconnect(); // notify of harsh disconnect notifyClose(StatusCode.NO_CLOSE,"Harsh disconnect"); }
@Override public WebSocketRemoteEndpoint newRemoteEndpoint(LogicalConnection connection, OutgoingFrames outgoingFrames, BatchMode batchMode) { return new WebSocketRemoteEndpoint(connection,outgoingHandler,getBatchMode()); }
@Override public ByteBuffer getPayload() { if (super.getPayload() == null) { return BufferUtil.EMPTY_BUFFER; } return super.getPayload(); } }
@Override public WebSocketSession createSession(URI requestURI, EventDriver websocket, LogicalConnection connection) { return new WebSocketSession(containerScope, requestURI,websocket,connection); } }
/** * Get the InetSocketAddress for the established connection. * * @return the InetSocketAddress for the established connection. (or null, if the connection is no longer established) */ @Override public InetSocketAddress getInetSocketAddress() { if(connection == null) return null; return connection.getRemoteAddress(); }
@Override public InetSocketAddress getLocalAddress() { return connection.getLocalAddress(); }
/** * Copy constructor for the websocket frame. * <p> * Note: the underlying payload is merely a {@link ByteBuffer#slice()} of the input frame. * * @param copy * the websocket to copy. */ public WebSocketFrame(WebSocketFrame copy) { copy(copy,copy.data); }
/** * Set the accepted WebSocket Protocol. * * @param protocol * the protocol to list as accepted */ @Override public void setAcceptedSubProtocol(String protocol) { setHeader(SEC_WEBSOCKET_PROTOCOL,protocol); }
@Override public void succeeded() { disconnect(); } }
/** * The idle timeout in milliseconds */ @Override public long getIdleTimeout() { return connection.getMaxIdleTimeout(); }
public WebSocketFrame asFrame() { WebSocketFrame frame = new WebSocketFrame(OpCode.CLOSE); frame.setFin(true); frame.setPayload(asByteBuffer()); return frame; }
@Override public void setMask(WebSocketFrame frame) { frame.setMask(mask); } }