use of org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage in project jetty.project by eclipse.
the class RFCSocket method onText.
@OnWebSocketMessage
public void onText(String message) throws IOException {
LOG.debug("onText({})", message);
// trigger a WebSocket server terminated close.
if (message.equals("CRASH")) {
throw new RuntimeException("Something bad happened");
}
// echo the message back.
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 jetty.project by eclipse.
the class ABSocket method onBinary.
@OnWebSocketMessage
public void onBinary(byte[] buf, int offset, int len) {
LOG.debug("onBinary(byte[{}],{},{})", buf.length, offset, len);
// echo the message back.
ByteBuffer data = ByteBuffer.wrap(buf, offset, len);
this.session.getRemote().sendBytes(data, null);
}
use of org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage in project jetty.project by eclipse.
the class InfoSocket method onMessage.
@OnWebSocketMessage
public void onMessage(String msg) {
RemoteEndpoint remote = this.session.getRemote();
remote.sendStringByFuture("session.maxTextMessageSize=" + session.getPolicy().getMaxTextMessageSize());
}
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);
}
}
}
use of org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage in project pulsar by yahoo.
the class SimpleConsumerSocket method onMessage.
@OnWebSocketMessage
public synchronized void onMessage(String msg) throws JsonParseException, IOException {
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());
receivedMessages.incrementAndGet();
}
Aggregations