Search in sources :

Example 1 with WebSocketPartialListener

use of org.eclipse.jetty.websocket.api.WebSocketPartialListener in project jetty.project by eclipse.

the class JettyListenerEventDriver method onTextFrame.

@Override
public void onTextFrame(ByteBuffer buffer, boolean fin) throws IOException {
    if (listener instanceof WebSocketListener) {
        if (activeMessage == null) {
            activeMessage = new SimpleTextMessage(this);
        }
        appendMessage(buffer, fin);
    }
    if (listener instanceof WebSocketPartialListener) {
        if (utf8Partial == null) {
            utf8Partial = new Utf8PartialBuilder();
        }
        String partial = utf8Partial.toPartialString(buffer);
        ((WebSocketPartialListener) listener).onWebSocketPartialText(partial, fin);
        if (fin) {
            partial = null;
        }
    }
}
Also used : WebSocketListener(org.eclipse.jetty.websocket.api.WebSocketListener) SimpleTextMessage(org.eclipse.jetty.websocket.common.message.SimpleTextMessage) Utf8PartialBuilder(org.eclipse.jetty.websocket.common.util.Utf8PartialBuilder) WebSocketPartialListener(org.eclipse.jetty.websocket.api.WebSocketPartialListener)

Aggregations

WebSocketListener (org.eclipse.jetty.websocket.api.WebSocketListener)1 WebSocketPartialListener (org.eclipse.jetty.websocket.api.WebSocketPartialListener)1 SimpleTextMessage (org.eclipse.jetty.websocket.common.message.SimpleTextMessage)1 Utf8PartialBuilder (org.eclipse.jetty.websocket.common.util.Utf8PartialBuilder)1