我必须在套接字关闭上做一些清理工作。我有一个TCPEventBusBridge
TcpEventBusBridge bridge = TcpEventBusBridge.create(vertx, opts);
bridge.listen(7000, res -> System.out.println("TCP Server Ready"));
答案 0 :(得分:0)
在Vert.x中,您可以使用BridgeEventType和SockJSHandler来检测TCP套接字关闭。
SockJSHandler ebHandler = SockJSHandler.create(vertx).bridge(opts , be->{
if (be.type() == BridgeEventType.PUBLISH || be.type() == BridgeEventType.RECEIVE) {
// connection event handling
}
if (be.type() == BridgeEventType.SOCKET_CLOSED ) {
// close event handling
}
be.complete(Constants.TRUE);
});