Package org.jboss.netty.handler.codec.http.websocketx

Examples of org.jboss.netty.handler.codec.http.websocketx.TextWebSocketFrame


    }

    @Override
    public void handle(WebSocketPacketMessage webSocketPacketMessage, Channel channel) throws IOException {
        ChannelBuffer message = encoder.encodePacket(webSocketPacketMessage.getPacket());
        WebSocketFrame res = new TextWebSocketFrame(message);
        log.trace("Out message: {} sessionId: {}", new Object[] {
                message.toString(CharsetUtil.UTF_8), webSocketPacketMessage.getSessionId()});
        if (channel.isOpen()) {
            channel.write(res);
        } else {
View Full Code Here


    }

    @Override
    public void handle(WebsocketErrorMessage websocketErrorMessage, Channel channel) throws IOException {
        ChannelBuffer message = encoder.encodePacket(websocketErrorMessage.getPacket());
        TextWebSocketFrame frame = new TextWebSocketFrame(message);
        channel.write(frame);
    }
View Full Code Here

    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
        Object msg = e.getMessage();
        if (msg instanceof CloseWebSocketFrame) {
            ctx.getChannel().close();
        } else if (msg instanceof TextWebSocketFrame) {
            TextWebSocketFrame frame = (TextWebSocketFrame) msg;
            receivePackets(ctx, frame.getBinaryData());
        } else if (msg instanceof HttpRequest) {
            HttpRequest req = (HttpRequest) msg;
            QueryStringDecoder queryDecoder = new QueryStringDecoder(req.getUri());
            String path = queryDecoder.getPath();
            if (path.startsWith(this.path)) {
View Full Code Here

            XContentBuilder forwardBuilder = jsonBuilder();
            forwardBuilder.startObject()
                    .field("channel", channelId)
                    .rawField("message", builder.bytes())
                    .endObject();
            final TextWebSocketFrame frame = new NettyInteractiveResponse("forward", forwardBuilder).response();
            // use a websocket client pool
            WebSocketClient client = nodeChannels.get(websocketNodeAddress);
            if (client == null) {
                final URI uri = new URI("ws:/" + websocketNodeAddress + "/websocket");
                client = clientFactory.newClient(uri, new WebSocketActionListener() {
View Full Code Here

                .startObject().field("success", true).field("type", type);
        if (builder != null) {
            responseBuilder.rawField("data", builder.bytes());
        }
        responseBuilder.endObject();
        this.response = new TextWebSocketFrame(responseBuilder.string());
    }
View Full Code Here

    public NettyInteractiveResponse(String type, Map<String, Object> map) throws IOException {
        this.type = type;
        XContentBuilder responseBuilder = jsonBuilder();
        responseBuilder.startObject().field("success", true).field("type", type).field("data", map).endObject();
        this.response = new TextWebSocketFrame(responseBuilder.string());
    }
View Full Code Here

        this.response = new TextWebSocketFrame(responseBuilder.string());
    }

    public NettyInteractiveResponse(String type, Throwable t) {
        this.type = type;
        this.response = new TextWebSocketFrame("{\"success\":false,\"type\":\"" + type + "\",\"error\":\"" + t.getMessage() + "\"");
    }
View Full Code Here

        return map;
    }

    private void error(String message, Channel channel) {
        String text = "{\"ok\":false,\"error\":\"" + message + "\"}";
        TextWebSocketFrame frame = new TextWebSocketFrame(text);
        channel.write(frame);
    }
View Full Code Here

                    new WebSocketActionListener() {
                        @Override
                        public void onConnect(WebSocketClient client) {
                            try {
                                logger.info("sending subscribe command");
                                client.send(new TextWebSocketFrame("{\"type\":\"subscribe\",\"data\":{\"subscriber\":\"mypubsubdemo\",\"topic\":\"demo\"}}"));
                                Thread.sleep(500);
                                logger.info("sending publish command (to ourselves)");
                                client.send(new TextWebSocketFrame("{\"type\":\"publish\",\"data\":{\"message\":\"Hello World\",\"topic\":\"demo\"}}"));
                            } catch (Exception e) {
                                logger.error(e.getMessage(), e);
                            }
                        }
View Full Code Here

                    new WebSocketActionListener() {
                        @Override
                        public void onConnect(WebSocketClient client) {
                            logger.info("web socket connected");
                            String s = "{\"Hello\":\"World\"}";
                            client.send(new TextWebSocketFrame(s));
                            logger.info("sent " + s);
                        }

                        @Override
                        public void onDisconnect(WebSocketClient client) {
View Full Code Here

TOP

Related Classes of org.jboss.netty.handler.codec.http.websocketx.TextWebSocketFrame

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.