コード例 #1
0
  private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
    // Check for closing frame
    if (frame instanceof CloseWebSocketFrame) {
      handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain());
      return;
    }

    if (frame instanceof PingWebSocketFrame) {
      ctx.channel().writeAndFlush(new PongWebSocketFrame(frame.content().retain()));
      return;
    }

    if (frame instanceof ContinuationWebSocketFrame) return;

    if (frame instanceof TextWebSocketFrame)
      webSocketActor.onMessage(((TextWebSocketFrame) frame).text());
    else webSocketActor.onMessage(frame.content().nioBuffer());
  }
コード例 #2
0
 @Override
 public final void close(Throwable t) {
   if (actor != null) actor.die(t);
   close();
 }
コード例 #3
0
 @Override
 public final void close() {
   if (ctx.channel().isOpen()) ctx.close();
   if (actor != null) actor.die(null);
 }