当前位置: 首页>>代码示例>>Java>>正文


Java WebSocketFrameInternal类代码示例

本文整理汇总了Java中org.vertx.java.core.http.impl.ws.WebSocketFrameInternal的典型用法代码示例。如果您正苦于以下问题:Java WebSocketFrameInternal类的具体用法?Java WebSocketFrameInternal怎么用?Java WebSocketFrameInternal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WebSocketFrameInternal类属于org.vertx.java.core.http.impl.ws包,在下文中一共展示了WebSocketFrameInternal类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: VertxServerWebSocket

import org.vertx.java.core.http.impl.ws.WebSocketFrameInternal; //导入依赖的package包/类
public VertxServerWebSocket(org.vertx.java.core.http.ServerWebSocket socket) {
  this.socket = socket;
  socket.closeHandler(new VoidHandler() {
    @Override
    protected void handle() {
      closeActions.fire();
    }
  })
  .exceptionHandler(new Handler<Throwable>() {
    @Override
    public void handle(Throwable throwable) {
      errorActions.fire(throwable);
    }
  })
  .frameHandler(new Handler<WebSocketFrame>() {
    @Override
    public void handle(WebSocketFrame f) {
      // Deal with only data frames
      WebSocketFrameInternal frame = (WebSocketFrameInternal) f;
      switch (frame.type()) {
        case TEXT:
          textActions.fire(frame.textData());
          break;
        case BINARY:
          binaryActions.fire(frame.getBinaryData().nioBuffer());
          break;
        default:
          break;
      }
    }
  });
}
 
开发者ID:cettia,项目名称:asity,代码行数:33,代码来源:VertxServerWebSocket.java

示例2: start

import org.vertx.java.core.http.impl.ws.WebSocketFrameInternal; //导入依赖的package包/类
public void start(int port) {

        vertx = VertxFactory.newVertx();

        httpServer = vertx.createHttpServer();
        httpServer.websocketHandler(new Handler<ServerWebSocket>() {
            public void handle(final ServerWebSocket ws) {

                if (ws.path().equals("/echo")) {

                    ws.frameHandler(new Handler<WebSocketFrame>() {
                        @Override
                        public void handle(WebSocketFrame webSocketFrame) {
                            if (webSocketFrame.isBinary()) {
                                Buffer buff = new Buffer(((WebSocketFrameInternal) webSocketFrame).getBinaryData());
                                ws.writeBinaryFrame(buff);
                            } else if (webSocketFrame.isText()) {
                                ws.writeTextFrame(webSocketFrame.textData());
                            }
                        }
                    });

                } else {
                    ws.reject();
                }
            }
        }).listen(port);
    }
 
开发者ID:matzew,项目名称:simple-websocket-client,代码行数:29,代码来源:WebSocketServer.java

示例3: VertxServerWebSocket

import org.vertx.java.core.http.impl.ws.WebSocketFrameInternal; //导入依赖的package包/类
public VertxServerWebSocket(org.vertx.java.core.http.ServerWebSocket socket) {
    this.socket = socket;
    socket.closeHandler(new VoidHandler() {
        @Override
        protected void handle() {
            closeActions.fire();
        }
    })
    .exceptionHandler(new Handler<Throwable>() {
        @Override
        public void handle(Throwable throwable) {
            errorActions.fire(throwable);
        }
    })
    .frameHandler(new Handler<WebSocketFrame>() {
        @Override
        public void handle(WebSocketFrame f) {
            // Deal with only data frames
            WebSocketFrameInternal frame = (WebSocketFrameInternal) f;
            switch (frame.type()) {
            case TEXT:
                textActions.fire(frame.textData());
                break;
            case BINARY:
                binaryActions.fire(frame.getBinaryData().nioBuffer());
                break;
            default:
                break;
            }
        }
    });
}
 
开发者ID:vibe-project,项目名称:vibe-java-platform,代码行数:33,代码来源:VertxServerWebSocket.java


注:本文中的org.vertx.java.core.http.impl.ws.WebSocketFrameInternal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。