Search in sources :

Example 16 with OnWebSocketMessage

use of org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage in project pulsar by yahoo.

the class SimpleTestProducerSocket method onMessage.

@OnWebSocketMessage
public void onMessage(String msg) throws JsonParseException {
    JsonObject json = new Gson().fromJson(msg, JsonObject.class);
    long endTimeNs = System.nanoTime();
    long startTime = endTimeNs;
    if (startTimeMap.get(json.get(CONTEXT)) != null)
        startTime = startTimeMap.get(json.get(CONTEXT));
    long latencyNs = endTimeNs - startTime;
    recorder.recordValue(NANOSECONDS.toMicros(latencyNs));
}
Also used : JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) OnWebSocketMessage(org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage)

Aggregations

OnWebSocketMessage (org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage)16 RemoteEndpoint (org.eclipse.jetty.websocket.api.RemoteEndpoint)9 ByteBuffer (java.nio.ByteBuffer)4 Gson (com.google.gson.Gson)3 JsonObject (com.google.gson.JsonObject)3 IOException (java.io.IOException)2 WebSocketMessage (org.springframework.web.reactive.socket.WebSocketMessage)2 JsonPrimitive (com.google.gson.JsonPrimitive)1 InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 URL (java.net.URL)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 List (java.util.List)1 Document (org.dom4j.Document)1 XMPPPacketReader (org.dom4j.io.XMPPPacketReader)1 UnknownStanzaException (org.jivesoftware.openfire.multiplex.UnknownStanzaException)1