Search in sources :

Example 1 with MessageAppender

use of org.eclipse.jetty.websocket.common.message.MessageAppender in project jetty.project by eclipse.

the class JettyAnnotatedEventDriver method onTextFrame.

@Override
public void onTextFrame(ByteBuffer buffer, boolean fin) throws IOException {
    if (events.onText == null) {
        // not interested in text events
        return;
    }
    if (activeMessage == null) {
        if (events.onText.isStreaming()) {
            activeMessage = new MessageReader(new MessageInputStream());
            final MessageAppender msg = activeMessage;
            dispatch(new Runnable() {

                @Override
                public void run() {
                    try {
                        events.onText.call(websocket, session, msg);
                    } catch (Throwable t) {
                        // dispatched calls need to be reported
                        onError(t);
                    }
                }
            });
        } else {
            activeMessage = new SimpleTextMessage(this);
        }
    }
    appendMessage(buffer, fin);
}
Also used : MessageInputStream(org.eclipse.jetty.websocket.common.message.MessageInputStream) SimpleTextMessage(org.eclipse.jetty.websocket.common.message.SimpleTextMessage) MessageReader(org.eclipse.jetty.websocket.common.message.MessageReader) MessageAppender(org.eclipse.jetty.websocket.common.message.MessageAppender)

Example 2 with MessageAppender

use of org.eclipse.jetty.websocket.common.message.MessageAppender in project jetty.project by eclipse.

the class JettyAnnotatedEventDriver method onBinaryFrame.

@Override
public void onBinaryFrame(ByteBuffer buffer, boolean fin) throws IOException {
    if (events.onBinary == null) {
        // not interested in binary events
        return;
    }
    if (activeMessage == null) {
        if (events.onBinary.isStreaming()) {
            activeMessage = new MessageInputStream();
            final MessageAppender msg = activeMessage;
            dispatch(new Runnable() {

                @Override
                public void run() {
                    try {
                        events.onBinary.call(websocket, session, msg);
                    } catch (Throwable t) {
                        // dispatched calls need to be reported
                        onError(t);
                    }
                }
            });
        } else {
            activeMessage = new SimpleBinaryMessage(this);
        }
    }
    appendMessage(buffer, fin);
}
Also used : MessageInputStream(org.eclipse.jetty.websocket.common.message.MessageInputStream) SimpleBinaryMessage(org.eclipse.jetty.websocket.common.message.SimpleBinaryMessage) MessageAppender(org.eclipse.jetty.websocket.common.message.MessageAppender)

Aggregations

MessageAppender (org.eclipse.jetty.websocket.common.message.MessageAppender)2 MessageInputStream (org.eclipse.jetty.websocket.common.message.MessageInputStream)2 MessageReader (org.eclipse.jetty.websocket.common.message.MessageReader)1 SimpleBinaryMessage (org.eclipse.jetty.websocket.common.message.SimpleBinaryMessage)1 SimpleTextMessage (org.eclipse.jetty.websocket.common.message.SimpleTextMessage)1