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

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


        logger.trace("WebSocket.write()");

        if (binaryWrite) {
            channel.write(new BinaryWebSocketFrame(ChannelBuffers.wrappedBuffer(data.getBytes("UTF-8"))));
        } else {
            channel.write(new TextWebSocketFrame(data));
        }
        lastWrite = System.currentTimeMillis();
        return this;
    }
View Full Code Here


        if (!channel.isOpen()) throw new IOException("Connection remotely closed");

        if (binaryWrite) {
            channel.write(new BinaryWebSocketFrame(ChannelBuffers.wrappedBuffer(data, offset, length)));
        } else {
            channel.write(new TextWebSocketFrame(ChannelBuffers.wrappedBuffer(data, offset, length)));
        }
        lastWrite = System.currentTimeMillis();
    }
View Full Code Here

    Object message = ((MessageEvent)e).getMessage();
    if(!(message instanceof JSONObject) && !(message instanceof CharSequence)) {
            ctx.sendDownstream(e);
            return;     
    }
    WebSocketFrame frame = new TextWebSocketFrame(message.toString());   
    ctx.sendDownstream(new DownstreamMessageEvent(channel, Channels.future(channel), frame, channel.getRemoteAddress()));   

  }
View Full Code Here

        }

        // Send the uppercase string back.
        String request = ((TextWebSocketFrame) frame).getText();
        log.info(String.format("Channel %s received %s", ctx.getChannel().getId(), request));
        ctx.getChannel().write(new TextWebSocketFrame(request.toUpperCase()));
   
  }
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 TextWebSocketFrame(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 TextWebSocketFrame(jsonString));
          }
        } else {         
          channel.channel.write(new TextWebSocketFrame(jsonString));
        }
      }
    }
  }
View Full Code Here

      Object msg) throws Exception
  {
    Event event = null;
    try
    {
      TextWebSocketFrame frame = (TextWebSocketFrame) msg;
      event = gson.fromJson(frame.getText(), DefaultEvent.class);
      if (event.getType() == Events.NETWORK_MESSAGE)
      {
        event.setType(Events.SESSION_MESSAGE);
      }
    }
View Full Code Here

  @Override
  protected Object encode(ChannelHandlerContext ctx, Channel channel,
      Object msg) throws Exception
  {
    String json = gson.toJson(msg);
    return new TextWebSocketFrame(json);
  }
View Full Code Here

      throws Exception
  {
    Channel channel = ctx.getChannel();
    if (e.getMessage() instanceof TextWebSocketFrame)
    {
      TextWebSocketFrame frame = (TextWebSocketFrame) e.getMessage();
      String data = frame.getText();
      LOG.trace("From websocket: " + data);
      Event event = gson.fromJson(data, DefaultEvent.class);
      int type = event.getType();
      if (Events.LOG_IN == type)
      {
View Full Code Here

  }

  protected TextWebSocketFrame eventToFrame(byte opcode, Object payload)
  {
    Event event = Events.event(payload, opcode);
    return new TextWebSocketFrame(gson.toJson(event));
  }
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.