Examples of Occupant


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

public class RoomOccupantTest {

  @Test
  public void shouldAnswerUnknownStatusWhenNotValid() {
    final Occupant occupant = new Occupant(uri("user@domain"), uri("room@domain/user"), "not valid affiliation", "not valid role", Show.unknown, "message");
    assertEquals(Occupant.Affiliation.none, occupant.getAffiliation());
    assertEquals(Occupant.Role.unknown, occupant.getRole());
    assertEquals(Show.unknown, occupant.getShow());
  }
View Full Code Here

Examples of org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Occupant

    public void testEnterRoom() throws Exception {
        chat.join("Nick");

        Room room = conference.findRoom(TestUtil.parseUnchecked(ROOM_JID));
        assertEquals(1, room.getOccupantCount());
        Occupant occupant = room.getOccupants().iterator().next();
        assertEquals(TEST_USERNAME1, occupant.getJid().getBareJID().getFullQualifiedName());
        assertEquals("Nick", occupant.getName());
       
       
        final BlockingQueue<String> joinedQueue = new LinkedBlockingQueue<String>();
        chat.addParticipantStatusListener(new ParticipantStatusListenerAdapter() {
           
View Full Code Here

Examples of org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Occupant

            }
           
            logger.debug("Received groupchat message to {}", roomJid);
            Room room = conference.findRoom(roomJid);
            if(room != null) {
                Occupant sendingOccupant = room.findOccupantByJID(from);
               
                // sender must be participant in room
                if(sendingOccupant != null) {
                   
                    Entity roomAndSendingNick = new EntityImpl(room.getJID(), sendingOccupant.getName());
                    if(sendingOccupant.hasVoice()) {
                        // relay message to all occupants in room
                       
                        try {
                            if(stanza.getSubjects() != null && !stanza.getSubjects().isEmpty()) {
                                // subject message
                                if(!room.isRoomType(RoomType.OpenSubject) && !sendingOccupant.isModerator()) {
                                    // room only allows moderators to change the subject, and sender is not a moderator
                                    return createMessageErrorStanza(room.getJID(), from, stanza.getID(), StanzaErrorType.AUTH, StanzaErrorCondition.FORBIDDEN, stanza);
                                }
                            }
                        } catch (XMLSemanticError e) {
                            // not a subject message, ignore exception
                        }
                       
                        logger.debug("Relaying message to all room occupants");
                        for(Occupant occupent : room.getOccupants()) {
                            logger.debug("Relaying message to  {}", occupent);
                            List<Attribute> replaceAttributes = new ArrayList<Attribute>();
                            replaceAttributes.add(new Attribute("from", roomAndSendingNick.getFullQualifiedName()));
                            replaceAttributes.add(new Attribute("to", occupent.getJid().getFullQualifiedName()));
                           
                            relayStanza(occupent.getJid(),
                                    StanzaBuilder.createClone(stanza, true, replaceAttributes).build(),
                                    serverRuntimeContext);
                           
                        }
                       
                        // add to discussion history
                        room.getHistory().append(stanza, sendingOccupant);
                    } else {
                        return createMessageErrorStanza(room.getJID(), from, stanza.getID(), StanzaErrorType.MODIFY, StanzaErrorCondition.FORBIDDEN, stanza);
                    }
                } else {
                    return createMessageErrorStanza(room.getJID(), from, stanza.getID(), StanzaErrorType.MODIFY, StanzaErrorCondition.NOT_ACCEPTABLE, stanza);
                }
            } else {
                return createMessageErrorStanza(moduleDomain, from, stanza.getID(), StanzaErrorType.MODIFY, StanzaErrorCondition.ITEM_NOT_FOUND, stanza);
            }
        } else if(type == null  || type == MessageStanzaType.CHAT || type == MessageStanzaType.NORMAL) {
            // private message
            logger.debug("Received direct message to {}", roomWithNickJid);
            Room room = conference.findRoom(roomJid);
            if(room != null) {
                Occupant sendingOccupant = room.findOccupantByJID(from);
               
                // sender must be participant in room
                    if(roomWithNickJid.isResourceSet()) {
                        if(sendingOccupant != null) {
                            // got resource, private message for occupant
                            Occupant receivingOccupant = room.findOccupantByNick(roomWithNickJid.getResource());
                           
                            // must be sent to an existing occupant in the room
                            if(receivingOccupant != null) {
                               
                                Entity roomAndSendingNick = new EntityImpl(room.getJID(), sendingOccupant.getName());
                                logger.debug("Relaying message to  {}", receivingOccupant);
                                List<Attribute> replaceAttributes = new ArrayList<Attribute>();
                                replaceAttributes.add(new Attribute("from", roomAndSendingNick.getFullQualifiedName()));
                                replaceAttributes.add(new Attribute("to", receivingOccupant.getJid().getFullQualifiedName()));
                               
                                relayStanza(receivingOccupant.getJid(),
                                        StanzaBuilder.createClone(stanza, true, replaceAttributes).build(),
                                        serverRuntimeContext);
                            } else {
                                // TODO correct error?
                                return createMessageErrorStanza(moduleDomain, from, stanza.getID(), StanzaErrorType.MODIFY, StanzaErrorCondition.ITEM_NOT_FOUND, stanza);
View Full Code Here

Examples of org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Occupant

        room.addOccupant(OCCUPANT1_JID, "nick");
        room.addOccupant(OCCUPANT2_JID, "nick 2");

        changeNick(OCCUPANT1_JID, new EntityImpl(ROOM1_JID, "new nick"));
       
        Occupant occupant = room.findOccupantByJID(OCCUPANT1_JID);
        assertEquals("new nick", occupant.getName());

        Item unavailbleItem = new Item(OCCUPANT1_JID, "new nick", Affiliation.None, Role.Participant);
        assertPresenceStanza(occupant1Queue.getNext(), new EntityImpl(ROOM1_JID, "nick"), OCCUPANT1_JID, "unavailable",
                Arrays.asList(unavailbleItem), Arrays.asList(StatusCode.NEW_NICK, StatusCode.OWN_PRESENCE));
        assertPresenceStanza(occupant2Queue.getNext(), new EntityImpl(ROOM1_JID, "nick"), OCCUPANT2_JID, "unavailable",
View Full Code Here

Examples of org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Occupant

*/
public class MUCMessageHandlerTestCase extends AbstractMUCMessageHandlerTestCase {

    public void testMessageWithNoVoice() throws Exception {
        Room room = conference.findOrCreateRoom(ROOM1_JID, "Room 1");
        Occupant occupant = room.addOccupant(OCCUPANT1_JID, "nick");
        // make sure the occupant has no voice
        occupant.setRole(Role.Visitor);

        testNotAllowedMessage(room, "forbidden");
    }
View Full Code Here

Examples of org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Occupant

        assertEquals(0, room.getOccupants().size());

        enterRoom(OCCUPANT1_JID, ROOM1_JID_WITH_NICK);

        assertEquals(1, room.getOccupants().size());
        Occupant occupant = room.getOccupants().iterator().next();
       
        assertEquals(OCCUPANT1_JID, occupant.getJid());
        assertEquals("nick", occupant.getName());
    }
View Full Code Here

Examples of org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Occupant

        // enter using the old groupchat protocol
        enterRoom(OCCUPANT1_JID, ROOM1_JID_WITH_NICK, null, null, true);

        assertEquals(1, room.getOccupants().size());
        Occupant occupant = room.getOccupants().iterator().next();
       
        assertEquals(OCCUPANT1_JID, occupant.getJid());
        assertEquals("nick", occupant.getName());
    }
View Full Code Here

Examples of org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Occupant

        Room room = conference.findRoom(ROOM1_JID);
        room.getAffiliations().add(OCCUPANT1_JID, Affiliation.Admin);

        enterRoom(OCCUPANT1_JID, ROOM1_JID_WITH_NICK);

        Occupant occupant = room.getOccupants().iterator().next();
       
        assertEquals(Affiliation.Admin, occupant.getAffiliation());
    }
View Full Code Here

Examples of org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Occupant

        enterRoom(OCCUPANT1_JID, ROOM2_JID_WITH_NICK);

        room = conference.findRoom(ROOM2_JID);
        assertNotNull(room);
        assertEquals(1, room.getOccupants().size());
        Occupant occupant = room.getOccupants().iterator().next();
       
        assertEquals(OCCUPANT1_JID, occupant.getJid());
        assertEquals("nick", occupant.getName());
    }
View Full Code Here

Examples of org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Occupant

    public void testDiscussionHistory() throws Exception {
        // add some messages
        Room room = conference.findOrCreateRoom(ROOM1_JID, "Room 1");
        room.getHistory().append(StanzaBuilder.createMessageStanza(OCCUPANT2_JID, ROOM1_JID, MessageStanzaType.GROUPCHAT, null, "Body").build(),
                new Occupant(OCCUPANT2_JID, "nick2", Affiliation.None, Role.Participant));
        room.getHistory().append(StanzaBuilder.createMessageStanza(OCCUPANT2_JID, ROOM1_JID, MessageStanzaType.GROUPCHAT, null, "Body2").build(),
                new Occupant(OCCUPANT2_JID, "nick2", Affiliation.None, Role.Participant));
        room.getHistory().append(StanzaBuilder.createMessageStanza(OCCUPANT2_JID, ROOM1_JID, MessageStanzaType.GROUPCHAT, null, "Body3").build(),
                new Occupant(OCCUPANT2_JID, "nick2", Affiliation.None, Role.Participant));
       
        // now, let user 1 enter room
        enterRoom(OCCUPANT1_JID, ROOM1_JID_WITH_NICK, null, new History(2, null, null, null), false);

        Stanza stanza = occupant1Queue.getNext();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.