本文整理汇总了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;
}
}
});
}
示例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);
}
示例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;
}
}
});
}