/** * Incoming Raw Frames from Parser */ @Override public void incomingFrame(Frame frame) { ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); if (connection.getIOState().isInputAvailable()) { // Forward Frames Through Extension List incomingHandler.incomingFrame(frame); } } finally { Thread.currentThread().setContextClassLoader(old); } }
/** * Incoming Errors from Parser */ @Override public void incomingError(WebSocketException e) { if (connection.getIOState().isInputClosed()) { return; // input is closed } // Forward Errors to User WebSocket Object websocket.incomingError(e); }
/** * Incoming Raw Frames from Parser */ @Override public void incomingFrame(Frame frame) { if (connection.getIOState().isInputClosed()) { return; // input is closed } // Forward Frames Through Extension List incomingHandler.incomingFrame(frame); }
/** * Incoming Raw Frames from Parser */ @Override public void incomingFrame(Frame frame) { if (connection.getIOState().isInputClosed()) { return; // input is closed } // Forward Frames Through Extension List incomingHandler.incomingFrame(frame); }
/** * Incoming Errors from Parser */ @Override public void incomingError(WebSocketException e) { if (connection.getIOState().isInputClosed()) { return; // input is closed } // Forward Errors to User WebSocket Object websocket.incomingError(e); }
@Override public RemoteEndpoint getRemote() { if(LOG_OPEN.isDebugEnabled()) LOG_OPEN.debug("[{}] {}.getRemote()",policy.getBehavior(),this.getClass().getSimpleName()); ConnectionState state = connection.getIOState().getConnectionState(); if ((state == ConnectionState.OPEN) || (state == ConnectionState.CONNECTED)) { return remote; } throw new WebSocketException("RemoteEndpoint unavailable, current state [" + state + "], expecting [OPEN or CONNECTED]"); }
public WebSocketSession(WebSocketContainerScope containerScope, URI requestURI, EventDriver websocket, LogicalConnection connection) { Objects.requireNonNull(containerScope,"Container Scope cannot be null"); Objects.requireNonNull(requestURI,"Request URI cannot be null"); this.classLoader = Thread.currentThread().getContextClassLoader(); this.containerScope = containerScope; this.requestURI = requestURI; this.websocket = websocket; this.connection = connection; this.executor = connection.getExecutor(); this.outgoingHandler = connection; this.incomingHandler = websocket; this.connection.getIOState().addListener(this); this.policy = websocket.getPolicy(); this.connection.setSession(this); addBean(this.connection); addBean(this.websocket); }
/** * Internal * * @param frame * the frame to write * @return the future for the network write of the frame */ private Future<Void> sendAsyncFrame(WebSocketFrame frame) { FutureWriteCallback future = new FutureWriteCallback(); try { connection.getIOState().assertOutputOpen(); outgoing.outgoingFrame(frame,future); } catch (IOException e) { future.writeFailed(e); } return future; }
/** * Internal * * @param frame * the frame to write * @return the future for the network write of the frame */ private Future<Void> sendAsyncFrame(WebSocketFrame frame) { FutureWriteCallback future = new FutureWriteCallback(); try { connection.getIOState().assertOutputOpen(); outgoing.outgoingFrame(frame,future); } catch (IOException e) { future.writeFailed(e); } return future; }
public void uncheckedSendFrame(WebSocketFrame frame, WriteCallback callback) { try { BatchMode batchMode = BatchMode.OFF; if (frame.isDataFrame()) batchMode = getBatchMode(); connection.getIOState().assertOutputOpen(); outgoing.outgoingFrame(frame, callback, batchMode); } catch (IOException e) { callback.writeFailed(e); } }
IOState ioState = this.connection.getIOState(); CloseInfo close = ioState.getCloseInfo();
/** * 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); }
connection.getIOState().onConnected(); connection.getIOState().onOpened();
/** * Blocking write of bytes. */ @Override public void sendBytes(ByteBuffer data) throws IOException { lockMsg(MsgType.BLOCKING); try { connection.getIOState().assertOutputOpen(); if (LOG.isDebugEnabled()) { LOG.debug("sendBytes with {}", BufferUtil.toDetailString(data)); } blockingWrite(new BinaryFrame().setPayload(data)); } finally { unlockMsg(MsgType.BLOCKING); } }
if (session.getConnection().getIOState().onCloseHandshake(true))
if (session.getConnection().getIOState().onCloseHandshake(true))
session.getConnection().getIOState().onCloseRemote(close);