Search in sources :

Example 6 with ConnectedMessage

use of org.apache.wicket.protocol.ws.api.message.ConnectedMessage in project wicket by apache.

the class WebSocketBehavior method onEvent.

@Override
public void onEvent(Component component, IEvent<?> event) {
    super.onEvent(component, event);
    Object payload = event.getPayload();
    if (payload instanceof WebSocketPayload) {
        WebSocketPayload<?> wsPayload = (WebSocketPayload<?>) payload;
        WebSocketRequestHandler webSocketHandler = wsPayload.getHandler();
        if (payload instanceof WebSocketTextPayload) {
            WebSocketTextPayload textPayload = (WebSocketTextPayload) payload;
            TextMessage data = textPayload.getMessage();
            onMessage(webSocketHandler, data);
        } else if (wsPayload instanceof WebSocketBinaryPayload) {
            WebSocketBinaryPayload binaryPayload = (WebSocketBinaryPayload) wsPayload;
            BinaryMessage binaryData = binaryPayload.getMessage();
            onMessage(webSocketHandler, binaryData);
        } else if (wsPayload instanceof WebSocketConnectedPayload) {
            WebSocketConnectedPayload connectedPayload = (WebSocketConnectedPayload) wsPayload;
            ConnectedMessage message = connectedPayload.getMessage();
            onConnect(message);
        } else if (wsPayload instanceof WebSocketClosedPayload) {
            WebSocketClosedPayload closedPayload = (WebSocketClosedPayload) wsPayload;
            ClosedMessage message = closedPayload.getMessage();
            onClose(message);
        } else if (wsPayload instanceof WebSocketErrorPayload) {
            WebSocketErrorPayload errorPayload = (WebSocketErrorPayload) wsPayload;
            ErrorMessage message = errorPayload.getMessage();
            onError(webSocketHandler, message);
        } else if (wsPayload instanceof WebSocketAbortedPayload) {
            WebSocketAbortedPayload abortedPayload = (WebSocketAbortedPayload) wsPayload;
            AbortedMessage message = abortedPayload.getMessage();
            onAbort(message);
        } else if (wsPayload instanceof WebSocketPushPayload) {
            WebSocketPushPayload pushPayload = (WebSocketPushPayload) wsPayload;
            IWebSocketPushMessage message = pushPayload.getMessage();
            onPush(webSocketHandler, message);
        }
    }
}
Also used : ClosedMessage(org.apache.wicket.protocol.ws.api.message.ClosedMessage) WebSocketAbortedPayload(org.apache.wicket.protocol.ws.api.event.WebSocketAbortedPayload) WebSocketPayload(org.apache.wicket.protocol.ws.api.event.WebSocketPayload) WebSocketConnectedPayload(org.apache.wicket.protocol.ws.api.event.WebSocketConnectedPayload) WebSocketTextPayload(org.apache.wicket.protocol.ws.api.event.WebSocketTextPayload) IWebSocketPushMessage(org.apache.wicket.protocol.ws.api.message.IWebSocketPushMessage) BinaryMessage(org.apache.wicket.protocol.ws.api.message.BinaryMessage) ConnectedMessage(org.apache.wicket.protocol.ws.api.message.ConnectedMessage) AbortedMessage(org.apache.wicket.protocol.ws.api.message.AbortedMessage) WebSocketBinaryPayload(org.apache.wicket.protocol.ws.api.event.WebSocketBinaryPayload) WebSocketPushPayload(org.apache.wicket.protocol.ws.api.event.WebSocketPushPayload) ErrorMessage(org.apache.wicket.protocol.ws.api.message.ErrorMessage) TextMessage(org.apache.wicket.protocol.ws.api.message.TextMessage) WebSocketErrorPayload(org.apache.wicket.protocol.ws.api.event.WebSocketErrorPayload) WebSocketClosedPayload(org.apache.wicket.protocol.ws.api.event.WebSocketClosedPayload)

Aggregations

ConnectedMessage (org.apache.wicket.protocol.ws.api.message.ConnectedMessage)6 AbortedMessage (org.apache.wicket.protocol.ws.api.message.AbortedMessage)4 ClosedMessage (org.apache.wicket.protocol.ws.api.message.ClosedMessage)3 IWebSocketPushMessage (org.apache.wicket.protocol.ws.api.message.IWebSocketPushMessage)3 WebSocketAbortedPayload (org.apache.wicket.protocol.ws.api.event.WebSocketAbortedPayload)2 WebSocketBinaryPayload (org.apache.wicket.protocol.ws.api.event.WebSocketBinaryPayload)2 WebSocketClosedPayload (org.apache.wicket.protocol.ws.api.event.WebSocketClosedPayload)2 WebSocketConnectedPayload (org.apache.wicket.protocol.ws.api.event.WebSocketConnectedPayload)2 WebSocketErrorPayload (org.apache.wicket.protocol.ws.api.event.WebSocketErrorPayload)2 WebSocketPayload (org.apache.wicket.protocol.ws.api.event.WebSocketPayload)2 WebSocketPushPayload (org.apache.wicket.protocol.ws.api.event.WebSocketPushPayload)2 WebSocketTextPayload (org.apache.wicket.protocol.ws.api.event.WebSocketTextPayload)2 BinaryMessage (org.apache.wicket.protocol.ws.api.message.BinaryMessage)2 ErrorMessage (org.apache.wicket.protocol.ws.api.message.ErrorMessage)2 TextMessage (org.apache.wicket.protocol.ws.api.message.TextMessage)2 IKey (org.apache.wicket.protocol.ws.api.registry.IKey)2 JQueryBehavior (com.googlecode.wicket.jquery.core.JQueryBehavior)1 DialogButton (com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton)1 MessageDialog (com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog)1 HttpSession (javax.servlet.http.HttpSession)1