private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {

    System.out.println("pre1:" + frame);

    // Check for closing frame
    if (frame instanceof CloseWebSocketFrame) {
      handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain());
      return;
    }
    if (frame instanceof PingWebSocketFrame) {
      ctx.channel().write(new PongWebSocketFrame(frame.content().retain()));
      return;
    }
    if (!(frame instanceof TextWebSocketFrame)) {
      throw new UnsupportedOperationException(
          String.format("%s frame types not supported", frame.getClass().getName()));
    }

    WebsocketMessageHandlerI websocketMessageHandler = new WebSocketMessageHander(ctx, channels);
    // Send the uppercase string back.

    String requestRaw = ((TextWebSocketFrame) frame).text();

    websocketMessageHandler.handleMessage(requestRaw);
  }
 private ChannelFuture handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
   // Check for closing frame
   if (frame instanceof CloseWebSocketFrame) {
     return Handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain());
   } else if (frame instanceof PingWebSocketFrame) {
     return ctx.channel().write(new PongWebSocketFrame(frame.content().retain()));
   } else if (frame instanceof TextWebSocketFrame) {
     TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
     String messageText = textFrame.text();
     return handleTextMessage(messageText);
   } else {
     throw new UnsupportedOperationException(
         String.format("%s frame types not supported", frame.getClass().getName()));
   }
 }
  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());
  }
  private void handlerWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {

    // �ж��Ƿ�ر���·��ָ��
    if (frame instanceof CloseWebSocketFrame) {
      handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain());
    }

    // �ж��Ƿ�ping��Ϣ
    if (frame instanceof PingWebSocketFrame) {
      ctx.channel().write(new PongWebSocketFrame(frame.content().retain()));
      return;
    }

    // �����̽�֧���ı���Ϣ����֧�ֶ�������Ϣ
    if (!(frame instanceof TextWebSocketFrame)) {

      System.out.println("�����̽�֧���ı���Ϣ����֧�ֶ�������Ϣ");

      throw new UnsupportedOperationException(
          String.format("%s frame types not supported", frame.getClass().getName()));
    }

    // ����Ӧ����Ϣ
    String request = ((TextWebSocketFrame) frame).text();

    System.out.println("������յ���" + request);

    if (logger.isLoggable(Level.FINE)) {
      logger.fine(String.format("%s received %s", ctx.channel(), request));
    }

    TextWebSocketFrame tws =
        new TextWebSocketFrame(new Date().toString() + ctx.channel().id() + "��" + request);

    // Ⱥ��
    Global.group.writeAndFlush(tws);

    // ���ء�˭���ķ���˭��
    // ctx.channel().writeAndFlush(tws);

  }
  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().write(new PongWebSocketFrame(frame.content().retain()));
      return;
    }
    if (!(frame instanceof TextWebSocketFrame)) {
      throw new UnsupportedOperationException(
          String.format("%s frame types not supported", frame.getClass().getName()));
    }

    // Send the uppercase string back.
    String request = ((TextWebSocketFrame) frame).text();
    System.err.printf("%s received %s%n", ctx.channel(), request);
    ctx.channel().write(new TextWebSocketFrame(request.toUpperCase()));
  }