Search in sources :

Example 21 with OnWebSocketMessage

use of org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage in project BIMserver by opensourceBIM.

the class WebSocketImpl method onBinary.

@OnWebSocketMessage
public void onBinary(byte[] bytes, int start, int length) {
    if (length == 0) {
        return;
    }
    ByteBuffer buffer = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN);
    long topicId = buffer.getLong();
    BinaryMessageListener binaryMessageListener = binaryMessageListeners.get(topicId);
    if (binaryMessageListener != null) {
        binaryMessageListener.newData(bytes, start, length);
    }
}
Also used : ByteBuffer(java.nio.ByteBuffer) OnWebSocketMessage(org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage)

Example 22 with OnWebSocketMessage

use of org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage in project incubator-pulsar by apache.

the class SimpleProducerSocket method onMessage.

@OnWebSocketMessage
public synchronized void onMessage(String msg) throws JsonParseException {
    JsonObject ack = new Gson().fromJson(msg, JsonObject.class);
    producerBuffer.add(ack.get("messageId").getAsString());
}
Also used : JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) OnWebSocketMessage(org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage)

Example 23 with OnWebSocketMessage

use of org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage in project Openfire by igniterealtime.

the class XmppWebSocket method onTextMethod.

@OnWebSocketMessage
public void onTextMethod(String stanza) {
    XMPPPacketReader reader = null;
    try {
        reader = readerPool.borrowObject();
        Document doc = reader.read(new StringReader(stanza));
        if (xmppSession == null) {
            initiateSession(doc.getRootElement());
        } else {
            processStanza(doc.getRootElement());
        }
    } catch (Exception ex) {
        Log.error("Failed to process XMPP stanza", ex);
    } finally {
        if (reader != null) {
            readerPool.returnObject(reader);
        }
    }
}
Also used : XMPPPacketReader(org.dom4j.io.XMPPPacketReader) StringReader(java.io.StringReader) Document(org.dom4j.Document) IOException(java.io.IOException) UnknownStanzaException(org.jivesoftware.openfire.multiplex.UnknownStanzaException) OnWebSocketMessage(org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage)

Aggregations

OnWebSocketMessage (org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage)23 RemoteEndpoint (org.eclipse.jetty.websocket.api.RemoteEndpoint)9 Gson (com.google.gson.Gson)6 JsonObject (com.google.gson.JsonObject)6 ByteBuffer (java.nio.ByteBuffer)6 IOException (java.io.IOException)4 JsonPrimitive (com.google.gson.JsonPrimitive)2 WebSocketMessage (org.springframework.web.reactive.socket.WebSocketMessage)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 OcppJsonError (de.rwth.idsg.steve.ocpp.ws.data.OcppJsonError)1 OcppJsonResponse (de.rwth.idsg.steve.ocpp.ws.data.OcppJsonResponse)1 OcppJsonResult (de.rwth.idsg.steve.ocpp.ws.data.OcppJsonResult)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 EOFException (java.io.EOFException)1 InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 ProtocolException (java.net.ProtocolException)1 SocketException (java.net.SocketException)1 SocketTimeoutException (java.net.SocketTimeoutException)1