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

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


                if (this.opcode == OPCODE_TEXT) {
                    if (frame.readableBytes() > MAX_LENGTH) {
                        throw new TooLongFrameException();
                    }
                    return new DefaultWebSocketFrame(0x00, frame);
                } else if (this.opcode == OPCODE_BINARY) {
                    return new DefaultWebSocketFrame(0xFF, frame);
                } else if (this.opcode == OPCODE_PING) {
                    channel.write(new Pong(0x00, frame));
                    return null;
                } else if (this.opcode == OPCODE_PONG) {
                    return new Pong(0x00, frame);
View Full Code Here


        return nettyHttpRequest;
    }

    @Override
    public NettyWebSocketConnection send(String message) {
        return send(new DefaultWebSocketFrame(message));
    }
View Full Code Here

        return send(new DefaultWebSocketFrame(message));
    }

    @Override
    public NettyWebSocketConnection send(byte[] message) {
        return send(new DefaultWebSocketFrame(0xFF, ChannelBuffers.wrappedBuffer(message)));
    }
View Full Code Here

        if (e.getMessage() instanceof HttpResponse) {
            HttpResponse response = (HttpResponse) e.getMessage();
            throw new WebSocketException("Unexpected HttpResponse (status=" + response.getStatus() + ", content=" + response.getContent().toString(CharsetUtil.UTF_8) + ")");
        }

        DefaultWebSocketFrame frame = (DefaultWebSocketFrame)e.getMessage();
        callback.onMessage(this, frame);
    }
View Full Code Here

        public String messageReceived = null;

        public void onConnect(WebSocketClient client) {
            System.out.println("WebSocket connected!");
            connected = true;
            client.send(new DefaultWebSocketFrame(TEST_MESSAGE));
        }
View Full Code Here

            p.remove("aggregator");
            p.replace("decoder", "wsdecoder", new WebSocketFrameDecoder());

            ctx.getChannel().write(res);
            p.replace("encoder", "wsencoder", new WebSocketFrameEncoder());
            ctx.getChannel().write(new DefaultWebSocketFrame("Welcome!"));
            return;
        }

        // Send an error page otherwise.
        sendHttpResponse(
View Full Code Here

    }

    private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
        // Send the uppercased string back.
        ctx.getChannel().write(
                new DefaultWebSocketFrame(frame.getTextData().toUpperCase()));
    }
View Full Code Here

  @Override
  protected Object encode(ChannelHandlerContext arg0, Channel arg1,
      Object m) throws Exception {
    if (m instanceof ChannelBuffer) {
      ChannelBuffer cbuf = (ChannelBuffer)m;
      WebSocketFrame frame = new DefaultWebSocketFrame(cbuf.toString(Charset.forName("utf8")));
      return frame;
    }
    return m;
  }
View Full Code Here

  protected Object decode(ChannelHandlerContext ctx, Channel arg1,
      Object m) throws Exception {
    if (!(m instanceof DefaultWebSocketFrame)) {
            return m;
        }    
        DefaultWebSocketFrame wsf = (DefaultWebSocketFrame)m;
       
        if (wsf.isBinary()) {
        return wsf.getBinaryData();
      } else if (wsf.isText()) {
        return ChannelBuffers.wrappedBuffer(wsf.getTextData().getBytes("utf8"));
      }
       
    return m;
  }
View Full Code Here

   */
  @Override
  public void sendPacket(WebSocketPacket aDataPacket) {
    if (handler.getChannelHandlerContext().getChannel().isConnected() && getEngine().isAlive()) {
      handler.getChannelHandlerContext().getChannel().write(
          new DefaultWebSocketFrame(aDataPacket.getString()));
    }
  }
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.