use of org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage in project jetty.project by eclipse.
the class BigEchoSocket method onText.
@OnWebSocketMessage
public void onText(Session session, String message) throws IOException {
if (!session.isOpen()) {
LOG.warn("Session is closed");
return;
}
RemoteEndpoint remote = session.getRemote();
remote.sendString(message, null);
if (remote.getBatchMode() == BatchMode.ON)
remote.flush();
}
use of org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage in project pulsar by yahoo.
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());
}
use of org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage in project incubator-pulsar by apache.
the class SimpleConsumerSocket method onMessage.
@OnWebSocketMessage
public synchronized void onMessage(String msg) throws JsonParseException, IOException {
receivedMessages.incrementAndGet();
JsonObject message = new Gson().fromJson(msg, JsonObject.class);
JsonObject ack = new JsonObject();
String messageId = message.get(X_PULSAR_MESSAGE_ID).getAsString();
consumerBuffer.add(messageId);
ack.add("messageId", new JsonPrimitive(messageId));
// Acking the proxy
this.getRemote().sendString(ack.toString());
}
use of org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage in project incubator-pulsar by apache.
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).getAsString()) != null) {
startTime = startTimeMap.get(json.get(CONTEXT).getAsString());
}
long latencyNs = endTimeNs - startTime;
recorder.recordValue(NANOSECONDS.toMicros(latencyNs));
}
use of org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage in project spring-framework by spring-projects.
the class JettyWebSocketHandlerAdapter method onWebSocketText.
@OnWebSocketMessage
public void onWebSocketText(String message) {
if (this.delegateSession != null) {
WebSocketMessage webSocketMessage = toMessage(Type.TEXT, message);
this.delegateSession.handleMessage(webSocketMessage.getType(), webSocketMessage);
}
}
Aggregations