Package javax.websocket

Examples of javax.websocket.CloseReason$CloseCode


                // Ran out of input data - get some more
                return false;
            } else {
                // Ran out of message buffer - flush it
                if (!usePartial()) {
                    CloseReason cr = new CloseReason(CloseCodes.TOO_BIG,
                            sm.getString("wsFrame.bufferTooSmall",
                                    Integer.valueOf(
                                            messageBufferBinary.capacity()),
                                    Long.valueOf(payloadLength)));
                    throw new WsIOException(cr);
View Full Code Here


        if (binaryMsgHandler != null) {
            if (binaryMsgHandler instanceof WrappedMessageHandler) {
                long maxMessageSize =
                        ((WrappedMessageHandler) binaryMsgHandler).getMaxMessageSize();
                if (maxMessageSize > -1 && msg.remaining() > maxMessageSize) {
                    throw new WsIOException(new CloseReason(CloseCodes.TOO_BIG,
                            sm.getString("wsFrame.messageTooBig",
                                    Long.valueOf(msg.remaining()),
                                    Long.valueOf(maxMessageSize))));
                }
            }
View Full Code Here

            try {
                wsFrame.onDataAvailable();
            } catch (WsIOException ws) {
                wsProtocolHandler.close(ws.getCloseReason());
            } catch (EOFException eof) {
                CloseReason cr = new CloseReason(
                        CloseCodes.CLOSED_ABNORMALLY, eof.getMessage());
                wsProtocolHandler.close(cr);
            } catch (IOException ioe) {
                onError(ioe);
            }
View Full Code Here

    }


    @Override
    public void close() throws IOException {
        close(new CloseReason(CloseCodes.NORMAL_CLOSURE, ""));
    }
View Full Code Here

            return;
        }

        if (System.currentTimeMillis() - lastActive > timeout) {
            String msg = sm.getString("wsSession.timeout");
            doClose(new CloseReason(CloseCodes.GOING_AWAY, msg),
                    new CloseReason(CloseCodes.CLOSED_ABNORMALLY, msg));
        }
    }
View Full Code Here

    @Override
    public synchronized void close() {
        for (ConfiguredServerEndpoint endpoint : configuredServerEndpoints) {
            for (Session session : endpoint.getOpenSessions()) {
                try {
                    session.close(new CloseReason(CloseReason.CloseCodes.GOING_AWAY, ""));
                } catch (Exception e) {
                    JsrWebSocketLogger.ROOT_LOGGER.couldNotCloseOnUndeploy(e);
                }
            }
        }
View Full Code Here

        return sessionId;
    }

    @Override
    public void close() throws IOException {
        close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, null));
    }
View Full Code Here

    @Override
    public void close(CloseReason closeReason) throws IOException {
        if(closed.compareAndSet(false, true)) {
            try {
                if(closeReason == null) {
                    endpoint.getInstance().onClose(this, new CloseReason(CloseReason.CloseCodes.NO_STATUS_CODE, null));
                } else {
                    endpoint.getInstance().onClose(this, closeReason);
                }
                if(!webSocketChannel.isCloseFrameReceived()) {
                    //if we have already recieved a close frame then the close frame handler
View Full Code Here

                WebSockets.sendClose(toSend, channel, null);
                try {
                    if (singleBuffer.remaining() > 1) {
                        final CloseReason.CloseCode code = CloseReason.CloseCodes.getCloseCode(singleBuffer.getShort());
                        final String reasonPhrase = singleBuffer.remaining() > 1 ? new UTF8Output(singleBuffer).extract() : null;
                        session.close(new CloseReason(code, reasonPhrase));
                    } else {
                        session.close();
                    }
                } catch (IOException e) {
                    invokeOnError(e);
View Full Code Here

                if (webSocketClose != null) {
                    try {
                        final Map<Class<?>, Object> params = new HashMap<Class<?>, Object>();
                        params.put(Session.class, session);
                        params.put(Map.class, session.getPathParameters());
                        params.put(CloseReason.class, new CloseReason(CloseReason.CloseCodes.getCloseCode(cm.getReason()), cm.getString()));
                        invokeMethod(params, webSocketClose, session);
                    } catch (Exception e) {
                        AnnotatedEndpoint.this.onError(session, e);
                    }
                }
View Full Code Here

TOP

Related Classes of javax.websocket.CloseReason$CloseCode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.