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

时间:2014-10-27 09:27:17

标签: playframework websocket

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

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()));
        }
    }

0 个答案:

没有答案