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

Examples of org.jboss.netty.handler.codec.http.websocket.DefaultWebSocketFrame


            @Override
            public void send(String data) {
                if (!isOpen()) {
                    throw new IllegalStateException("The outbound channel is closed");
                }
                writeAndClose(ctx.getChannel().write(new DefaultWebSocketFrame(data)));
            }

            @Override
            public void send(byte opcode, byte[] data, int offset, int length) {
                if (!isOpen()) {
                    throw new IllegalStateException("The outbound channel is closed");
                }
                writeAndClose(ctx.getChannel().write(new DefaultWebSocketFrame(opcode, wrappedBuffer(data, offset, length))));
            }

            @Override
            public synchronized boolean isOpen() {
                return ctx.getChannel().isOpen() && closeTask == null;
View Full Code Here


    public void sendUnencoded(String message) {
        if(!this.open) return;

        Channel chan = ctx.getChannel();
        if(chan.isOpen()) {
            chan.write(new DefaultWebSocketFrame(message));
        } else {
            this.disconnect();
        }
    }
View Full Code Here

                    return null;
                }

                try {
                    if (this.opcode == OPCODE_TEXT) {
                        return new DefaultWebSocketFrame(0x00, frame);
                    } else if (this.opcode == OPCODE_BINARY) {
                        return new DefaultWebSocketFrame(0xFF, frame);
                    } else if (this.opcode == OPCODE_PING) {
                        return new Pong(0x00, frame);
                    } else if (this.opcode == OPCODE_PONG) {
                        return null;
                    } else if (this.opcode == OPCODE_CLOSE) {
View Full Code Here

    @Override
    protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {

        if (msg instanceof DefaultWebSocketFrame) {
            final DefaultWebSocketFrame frame = (DefaultWebSocketFrame) msg;

            ChannelBuffer data = frame.getBinaryData();
      if (data == null) {
        data = ChannelBuffers.EMPTY_BUFFER;
      }

            byte opcode;
            // TODO: Close and CONTINUATION
            if(frame instanceof Ping) {
                opcode = OPCODE_PING;
            } else if(frame instanceof Pong) {
                opcode = OPCODE_PONG;
            } else {
                opcode = frame.isText() ? OPCODE_TEXT : OPCODE_BINARY;
            }


            int length = data.readableBytes();
View Full Code Here

            @Override
            public void send(String data) {
                if (!isOpen()) {
                    throw new IllegalStateException("The outbound channel is closed");
                }
                writeAndClose(ctx.getChannel().write(new DefaultWebSocketFrame(data)));
            }

            @Override
            public void send(byte opcode, byte[] data, int offset, int length) {
                if (!isOpen()) {
                    throw new IllegalStateException("The outbound channel is closed");
                }

                writeAndClose(ctx.getChannel().write(new DefaultWebSocketFrame(opcode, wrappedBuffer(data, offset, length))));
            }

            @Override
            public synchronized boolean isOpen() {
                return ctx.getChannel().isOpen() && closeTask == null;
View Full Code Here

    @Override
    public NettyWebSocketConnection send(String message) {
        if (hybi) {
            writeMessage(new EncodingHybiFrame(Opcodes.OPCODE_TEXT, true, 0, outboundMaskingKey, ChannelBuffers.copiedBuffer(message, CharsetUtil.UTF_8)));
        } else {
            writeMessage(new DefaultWebSocketFrame(message));
        }
        return this;
    }
View Full Code Here

            @Override
            public void send(String data) {
                if (!isOpen()) {
                    throw new IllegalStateException("The outbound channel is closed");
                }
                writeAndClose(ctx.getChannel().write(new DefaultWebSocketFrame(data)));
            }

            @Override
            public void send(byte opcode, byte[] data, int offset, int length) {
                if (!isOpen()) {
                    throw new IllegalStateException("The outbound channel is closed");
                }
                writeAndClose(ctx.getChannel().write(new DefaultWebSocketFrame(opcode, wrappedBuffer(data, offset, length))));
            }

            @Override
            public synchronized boolean isOpen() {
                return ctx.getChannel().isOpen() && closeTask == null;
View Full Code Here

         // since HornetQ protocol SPI requires to return HornetQBuffer to the transport
         HornetQBuffer buffer = new ChannelBufferWrapper((ChannelBuffer)msg);
         StompFrame frame = decoder.decode(buffer);
         if (frame != null)
         {
            WebSocketFrame wsFrame = new DefaultWebSocketFrame(frame.asString());

            // Text frame
            ChannelBuffer data = wsFrame.getBinaryData();
            ChannelBuffer encoded = channel.getConfig().getBufferFactory().getBuffer(data.order(),
                                                                                     data.readableBytes() + 2);
            encoded.writeByte((byte)wsFrame.getType());
            encoded.writeBytes(data, data.readableBytes());
            encoded.writeByte((byte)0xFF);
            return encoded;

         }
View Full Code Here

    Object value = cache.get(key);
   
    JSONObject responseObject = toJSON(key, value, cache.getName());
   
    // Write the JSON response out onto the channel...
    ctx.getChannel().write(new DefaultWebSocketFrame(responseObject.toString()));
  }
View Full Code Here

    String jsonString = jsonObject.toString();
    for(ChannelNotifyParams channel : channels) {
      if(channel.channel.isOpen() && channel.onEvents.contains(eventType)) {
        if(channel.key != null) {
          if(event.getKey().equals(channel.key) || channel.key.equals("*")) {
            channel.channel.write(new DefaultWebSocketFrame(jsonString));
          }
        } else {         
          channel.channel.write(new DefaultWebSocketFrame(jsonString));
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.jboss.netty.handler.codec.http.websocket.DefaultWebSocketFrame

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.