Package com.calclab.emite.xep.muc.client

Examples of com.calclab.emite.xep.muc.client.Room


    new ChatManagerEventsSupervisor(roomManager, display);
    new RoomManagerEventsSupervisor(roomManager, display);

    // Because is a RoomManager, we know this MUST be a room
    final Room room = (Room) roomManager.open(roomUri);
    room.addMessageReceivedHandler(new MessageHandler() {
      @Override
      public void onMessage(final MessageEvent event) {
        final Message message = event.getMessage();
        display.print(("RECEIVED: " + message.getBody()), Style.received);
        pongs++;
        if (room.isUserMessage(message) && !room.isComingFromMe(message)) {
          final String body = "Pong " + pongs + " [" + System.currentTimeMillis() + "]";
          room.send(new Message(body));
          display.print("SENT: " + body, Style.sent);
        }
      }
    });
  }
View Full Code Here


    display.printHeader("Ping to: " + otherUri, Style.info);

    new ChatManagerEventsSupervisor(roomManager, display);
    new RoomManagerEventsSupervisor(roomManager, display);

    final Room room = (Room) roomManager.open(roomUri);

    // When the room is ready, we invite other
    room.addChatStateChangedHandler(true, new StateChangedHandler() {
      @Override
      public void onStateChanged(final StateChangedEvent event) {
        if (event.is(ChatStates.ready)) {
          display.print("Room ready. Sending invitation to " + otherUri, Style.important);
          pings++;
          room.sendInvitationTo(otherUri, "ping invite " + pings);
        }
      }
    });

    room.addOccupantChangedHandler(new OccupantChangedHandler() {
      @Override
      public void onOccupantChanged(final OccupantChangedEvent event) {
        final boolean isOtherOccupant = event.getOccupant().getUserUri().equalsNoResource(otherUri);
        if (isOtherOccupant) {
          if (event.isRemoved()) {
            display.print("Invited removed... waiting to send invitation", Style.important);
            new Timer() {
              @Override
              public void run() {
                display.print("Sending invitation", Style.important);
                pings++;
                time += 1000;
                room.sendInvitationTo(otherUri, "ping invite " + pings);
              }
            }.schedule(time);
          } else if (event.isAdded()) {
            display.print("Change subject", Style.important);
            RoomSubject.requestSubjectChange(room, "Subject ping" + pings);
View Full Code Here

TOP

Related Classes of com.calclab.emite.xep.muc.client.Room

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.