Esempio n. 1
0
 private void deliverMessage(SockJSSocket sock, String address, Message message) {
   JsonObject envelope =
       new JsonObject().putString("address", address).putValue("body", message.body);
   if (message.replyAddress != null) {
     envelope.putString("replyAddress", message.replyAddress);
   }
   sock.writeBuffer(new Buffer(envelope.encode()));
 }
Esempio n. 2
0
  public void handle(final SockJSSocket sock) {

    final Map<String, Handler<Message>> handlers = new HashMap<>();

    sock.endHandler(
        new SimpleHandler() {
          public void handle() {
            handleSocketClosed(sock, handlers);
          }
        });

    sock.dataHandler(
        new Handler<Buffer>() {
          public void handle(Buffer data) {
            handleSocketData(sock, data, handlers);
          }
        });
  }