Search in sources :

Example 1 with JsrPongMessage

use of org.eclipse.jetty.websocket.jsr356.JsrPongMessage in project jetty.project by eclipse.

the class JsrEndpointEventDriver method onPongMessage.

private void onPongMessage(ByteBuffer buffer) {
    final MessageHandlerWrapper wrapper = jsrsession.getMessageHandlerWrapper(MessageType.PONG);
    if (wrapper == null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("No PONG MessageHandler declared");
        }
        return;
    }
    ByteBuffer pongBuf = null;
    if (BufferUtil.isEmpty(buffer)) {
        pongBuf = BufferUtil.EMPTY_BUFFER;
    } else {
        pongBuf = ByteBuffer.allocate(buffer.remaining());
        BufferUtil.put(buffer, pongBuf);
        BufferUtil.flipToFlush(pongBuf, 0);
    }
    @SuppressWarnings("unchecked") Whole<PongMessage> pongHandler = (Whole<PongMessage>) wrapper.getHandler();
    pongHandler.onMessage(new JsrPongMessage(pongBuf));
}
Also used : MessageHandlerWrapper(org.eclipse.jetty.websocket.jsr356.MessageHandlerWrapper) PongMessage(javax.websocket.PongMessage) JsrPongMessage(org.eclipse.jetty.websocket.jsr356.JsrPongMessage) ByteBuffer(java.nio.ByteBuffer) Whole(javax.websocket.MessageHandler.Whole) JsrPongMessage(org.eclipse.jetty.websocket.jsr356.JsrPongMessage)

Aggregations

ByteBuffer (java.nio.ByteBuffer)1 Whole (javax.websocket.MessageHandler.Whole)1 PongMessage (javax.websocket.PongMessage)1 JsrPongMessage (org.eclipse.jetty.websocket.jsr356.JsrPongMessage)1 MessageHandlerWrapper (org.eclipse.jetty.websocket.jsr356.MessageHandlerWrapper)1