Package com.nhncorp.mods.socket.io.impl

Examples of com.nhncorp.mods.socket.io.impl.Namespace


  public void start() {
    int port = 9191;
    HttpServer server = vertx.createHttpServer();
    SocketIOServer io = new DefaultSocketIOServer(vertx, server);

    final Namespace chat = io.of("/chat");
    chat.onConnection(new Handler<SocketIOSocket>() {
      public void handle(SocketIOSocket socket) {
        socket.on("namespace emit", new Handler<JsonObject>() {
          public void handle(JsonObject event) {
            chat.emit("msg", new JsonObject().putString("everyone", "in").putString("/chat", "will get"));
          }
        });
      }
    });

    final Namespace news = io.of("/news");
    news.onConnection(new Handler<SocketIOSocket>() {
      public void handle(SocketIOSocket socket) {
        socket.emit("item", new JsonObject().putString("news", "item"));
      }
    });
View Full Code Here


        });
      }

      private void newChannel(String channel) {
        final Namespace namespace = io.of("/" + channel);
        namespace.onConnection(new Handler<SocketIOSocket>() {
          @Override
          public void handle(SocketIOSocket socket) {
            socket.on("message", new Handler<JsonObject>() {
              @Override
              public void handle(JsonObject event) {
                System.out.println(event);
                namespace.emit("message", event.getString("data"));
              }
            });
          }
        });
      }
View Full Code Here

TOP

Related Classes of com.nhncorp.mods.socket.io.impl.Namespace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.