@Override public void appendMessage(ByteBuffer payload) throws IOException { if (finished) { throw new IOException("Cannot append to finished buffer"); } if (payload == null) { // empty payload is valid return; } onEvent.getPolicy().assertValidMessageSize(size + payload.remaining()); size += payload.remaining(); BufferUtil.writeTo(payload,out); }
/** * Incoming Errors */ @Override public void incomingError(Throwable t) { // Forward Errors to User WebSocket Object websocket.incomingError(t); }
@Override public void messageComplete() { finished = true; byte data[] = out.toByteArray(); onEvent.onBinaryMessage(data); } }
onFrame(frame); onClose(close); onBinaryFrame(frame.getPayload(),frame.isFin()); return; onTextFrame(frame.getPayload(),frame.isFin()); return; terminateConnection(StatusCode.BAD_PAYLOAD,e.getMessage()); terminateConnection(e.getStatusCode(),e.getMessage()); unhandled(t);
@Override public void close(int statusCode, String reason) { connection.close(statusCode,reason); websocket.onClose(new CloseInfo(statusCode,reason)); }
@Override public final void incomingError(WebSocketException e) { if (LOG.isDebugEnabled()) { LOG.debug("incoming(WebSocketException)",e); } if (e instanceof CloseException) { CloseException close = (CloseException)e; terminateConnection(close.getStatusCode(),close.getMessage()); } onError(e); }
@Override public void messageComplete() { finished = true; // notify event onEvent.onTextMessage(utf.toString()); } }
/** * Open/Activate the session * * @throws IOException */ public void open() { if (remote != null) { // already opened return; } // Connect remote remote = new WebSocketRemoteEndpoint(connection,outgoingHandler); // Open WebSocket websocket.openSession(this); if (LOG.isDebugEnabled()) { LOG.debug("open -> {}",dump()); } }
public void openSession(WebSocketSession session) { LOG.debug("openSession({})",session); this.session = session; this.onConnect(); }
@Override public void failed(Throwable cause) { // Notify websocket of failure to connect driver.onError(cause); // Notify promise/future of failure to connect super.failed(cause); }
onFrame(frame); onClose(close); onBinaryFrame(frame.getPayload(),frame.isFin()); return; onTextFrame(frame.getPayload(),frame.isFin()); return; terminateConnection(StatusCode.BAD_PAYLOAD,e.getMessage()); terminateConnection(e.getStatusCode(),e.getMessage()); unhandled(t);
/** * Harsh disconnect */ @Override public void disconnect() { connection.disconnect(); // notify of harsh disconnect websocket.onClose(new CloseInfo(StatusCode.NO_CLOSE,"Harsh disconnect")); }
@Override public final void incomingError(WebSocketException e) { if (LOG.isDebugEnabled()) { LOG.debug("incoming(WebSocketException)",e); } if (e instanceof CloseException) { CloseException close = (CloseException)e; terminateConnection(close.getStatusCode(),close.getMessage()); } onError(e); }
@Override public void messageComplete() { finished = true; // notify event onEvent.onTextMessage(utf.toString()); } }
/** * Open/Activate the session * * @throws IOException */ public void open() { if (remote != null) { // already opened return; } // Connect remote remote = new WebSocketRemoteEndpoint(connection,outgoingHandler); // Open WebSocket websocket.openSession(this); if (LOG.isDebugEnabled()) { LOG.debug("open -> {}",dump()); } }
public void openSession(WebSocketSession session) { LOG.debug("openSession({})",session); this.session = session; this.onConnect(); }
@Override public void failed(Throwable cause) { // Notify websocket of failure to connect driver.onError(cause); // Notify promise/future of failure to connect super.failed(cause); }
@Override public void appendMessage(ByteBuffer payload) throws IOException { if (finished) { throw new IOException("Cannot append to finished buffer"); } if (payload == null) { // empty payload is valid return; } onEvent.getPolicy().assertValidMessageSize(size + payload.remaining()); size += payload.remaining(); // allow for fast fail of BAD utf (incomplete utf will trigger on messageComplete) this.utf.append(payload); }
private void handleException(Throwable failure) { localEndpoint.incomingError(failure); fut.completeExceptionally(failure); }
/** * Harsh disconnect */ @Override public void disconnect() { connection.disconnect(); // notify of harsh disconnect websocket.onClose(new CloseInfo(StatusCode.NO_CLOSE,"Harsh disconnect")); }