Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过WebSocket发送Ping帧?我的Playframework版本是1.2.7_Playframework_Websocket - Fatal编程技术网

如何通过WebSocket发送Ping帧?我的Playframework版本是1.2.7

如何通过WebSocket发送Ping帧?我的Playframework版本是1.2.7,playframework,websocket,Playframework,Websocket,我只是在\framework\src\play\server\PlayHandler.java中找到Ping框架的一些源代码。 它将使用以下代码处理ping帧。 但是我找不到ping帧自动发送的时间?或者任何其他api来发送ping帧 private void websocketFrameReceived(final ChannelHandlerContext ctx, WebSocketFrame webSocketFrame) { Http.Inbound inbound =

我只是在\framework\src\play\server\PlayHandler.java中找到Ping框架的一些源代码。 它将使用以下代码处理ping帧。 但是我找不到ping帧自动发送的时间?或者任何其他api来发送ping帧

private void websocketFrameReceived(final ChannelHandlerContext ctx, WebSocketFrame webSocketFrame) {
        Http.Inbound inbound = channels.get(ctx);
        // Check for closing frame
        if (webSocketFrame instanceof CloseWebSocketFrame) {
            this.handshaker.close(ctx.getChannel(), (CloseWebSocketFrame) webSocketFrame);
        } else if (webSocketFrame instanceof PingWebSocketFrame) {
            ctx.getChannel().write(new PongWebSocketFrame(webSocketFrame.getBinaryData()));
        } else if (webSocketFrame instanceof BinaryWebSocketFrame) {
            inbound._received(new Http.WebSocketFrame(webSocketFrame.getBinaryData().array()));
        } else if (webSocketFrame instanceof TextWebSocketFrame) {
            inbound._received(new Http.WebSocketFrame(((TextWebSocketFrame)webSocketFrame).getText()));
        }
    }

我个人使用play jobs发送ping请求。在阅读之后,我做了如下操作:byte pingByte=9;字节[]pingData={9};发送(pingByte,pingData);