Package com.calclab.emite.xep.muc

Examples of com.calclab.emite.xep.muc.RoomChat


    chatManager.addRoomChatChangedHandler(this);
  }

  @Override
  public final void onRoomChatChanged(final RoomChatChangedEvent event) {
    final RoomChat room = event.getChat();
    if (event.isCreated()) {
      getRoomStateHook(room);
    } else if (event.isClosed()) {
      logger.finer("Removing chat state to chat: " + room.toString());
      hooks.remove(room);
    }
  }
View Full Code Here


    final String reason = "theReason";
    final XmppURI invitor = uri("friend@host/resource");
    final XmppURI roomURI = uri("room@room.service");
    manager.acceptRoomInvitation(new RoomInvitation(invitor, roomURI, reason));
    assertTrue(chatCreatedHandler.isCalledOnce());
    final RoomChat room = chatCreatedHandler.getLastChat();
    assertEquals("room@room.service/self", room.getURI().toString());
  }
View Full Code Here

    assertEquals("room@room.service/self", room.getURI().toString());
  }

  @Test
  public void shouldAcceptRoomPresenceWithAvatar() {
    final RoomChat room = manager.open(uri("room1@domain/nick"));
    session.receives("<presence to='user@domain/resource' from='room1@domain/otherUser2'>" + "<priority>0</priority>"
        + "<x xmlns='http://jabber.org/protocol/muc#user'>" + "<item jid='otheruserjid@domain/otherresoruce' affiliation='none' "
        + "role='participant'/></x>" + "<x xmlns='vcard-temp:x:update'><photo>af70fe6519d6a27a910c427c3bc551dcd36073e7</photo></x>" + "</presence>");
    assertEquals(1, room.getOccupantsCount());
    final Occupant occupant = room.getOccupantByOccupantUri(uri("room1@domain/otherUser2"));
    assertNotNull(occupant);
    assertEquals(Affiliation.none, occupant.getAffiliation());
    assertEquals(Role.participant, occupant.getRole());
  }
View Full Code Here

    session.verifyIQSent(new IQ(Type.set));
  }

  @Test
  public void shouldFireChatMessages() {
    final RoomChat chat = manager.open(uri("room@rooms.domain/user"));
    final MessageReceivedTestHandler handler = new MessageReceivedTestHandler();
    chat.addMessageReceivedHandler(handler);
    session.receives("<message from='room@rooms.domain/other' to='user@domain/resource' " + "type='groupchat'><body>the message body</body></message>");
    assertEquals(1, handler.getCalledTimes());
  }
View Full Code Here

    assertEquals(1, handler.getCalledTimes());
  }

  @Test
  public void shouldGiveSameRoomsWithSameURIS() {
    final RoomChat room1 = manager.open(uri("room@domain/nick"));
    final RoomChat room2 = manager.open(uri("room@domain/nick"));
    assertSame(room1, room2);
  }
View Full Code Here

    assertSame(room1, room2);
  }

  @Test
  public void shouldIgnoreLetterCaseInURIS() {
    final RoomChat room = manager.open(uri("ROOM@domain/nick"));
    final OccupantChangedTestHandler handler = new OccupantChangedTestHandler();
    room.addOccupantChangedHandler(handler);
    session.receives("<presence to='user@domain/resource' xmlns='jabber:client' from='ROom@domain/otherUser'>"
        + "<x xmlns='http://jabber.org/protocol/muc#user'>" + "<item role='moderator' affiliation='owner' jid='user@domain' /></x></presence>");
    assertTrue(handler.isCalledOnce());
  }
View Full Code Here

    final ChatProperties properties = new ChatProperties(roomURI);
    final String testDataKey = "TEST_KEY";
    final String testDataValue = "TEST_VALUE";
    properties.setData(testDataKey, testDataValue);
    manager.acceptRoomInvitation(new RoomInvitation(invitor, roomURI, reason, properties));
    final RoomChat room = chatCreatedHandler.getLastChat();
    assertEquals("Chat property not preserved", testDataValue, room.getProperties().getData(testDataKey));
  }
View Full Code Here

    assertEquals("Chat property not preserved", testDataValue, room.getProperties().getData(testDataKey));
  }

  @Test
  public void shouldUpdateRoomPresence() {
    final RoomChat room = manager.open(uri("room1@domain/nick"));

    session.receives("<presence to='user@domain/resource' xmlns='jabber:client' from='room1@domain/otherUser'>"
        + "<x xmlns='http://jabber.org/protocol/muc#user'>" + "<item role='moderator' affiliation='owner' jid='otherUser@domain' /></x></presence>");
    assertEquals(1, room.getOccupantsCount());
    Occupant user = room.getOccupantByOccupantUri(uri("room1@domain/otherUser"));
    assertNotNull(user);
    assertEquals(Affiliation.owner, user.getAffiliation());
    assertEquals(Role.moderator, user.getRole());

    session.receives("<presence to='user@domain/resource' xmlns='jabber:client' from='room1@domain/otherUser'>"
        + "<x xmlns='http://jabber.org/protocol/muc#user'>" + "<item role='participant' affiliation='member' /></x></presence>");
    assertEquals(1, room.getOccupantsCount());
    user = room.getOccupantByOccupantUri(uri("room1@domain/otherUser"));
    assertNotNull(user);
    assertEquals(Affiliation.member, user.getAffiliation());
    assertEquals(Role.participant, user.getRole());

    session.receives("<presence to='user@domain/res1' type='unavailable' " + "xmlns='jabber:client' from='room1@domain/otherUser'>"
        + "<status>custom message</status><x xmlns='http://jabber.org/protocol/muc#user'>" + "<item role='none' affiliation='member' /></x></presence>");
    assertEquals(0, room.getOccupantsCount());

  }
View Full Code Here

  }
 
  @Test
  public void shouldEventWhenAChatIsClosed() {
    final RoomChat chat = manager.open(uri("other@domain/resource"));
    final RoomChatChangedTestHandler handler = new RoomChatChangedTestHandler(ChangeType.closed);
    manager.addRoomChatChangedHandler(handler);
    manager.close(chat);
    assertTrue(handler.isCalledOnce());
  }
View Full Code Here

TOP

Related Classes of com.calclab.emite.xep.muc.RoomChat

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.