Examples of Occupant


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

        if(room.isInRoom(newOccupantJid)) {
            // user is already in room, change nick
            logger.debug("{} has requested to change nick in room {}", newOccupantJid, roomJid);

            // occupant is already in room
            Occupant occupant = room.findOccupantByJID(newOccupantJid);
            if(nick.equals(occupant.getName())) {
                // nick unchanged, change show and status
                for(Occupant receiver : room.getOccupants()) {
                    sendChangeShowStatus(occupant, receiver, room, getInnerElementText(stanza, "show"),
                            getInnerElementText(stanza, "status"), serverRuntimeContext);
                }
            } else {
                if(room.isInRoom(nick)) {
                    // user with this nick is already in room
                    return createPresenceErrorStanza(roomJid, newOccupantJid, stanza.getID(), "cancel", "conflict");
                }
               
                String oldNick = occupant.getName();
                // update the nick
                occupant.setName(nick);
               
                // send out unavailable presences to all existing occupants
                for(Occupant receiver : room.getOccupants()) {
                    sendChangeNickUnavailable(occupant, oldNick, receiver, room, serverRuntimeContext);
                }
               
                // send out available presences to all existing occupants
                for(Occupant receiver : room.getOccupants()) {
                    sendChangeNickAvailable(occupant, receiver, room, serverRuntimeContext);
                }

            }
        } else {
            logger.debug("{} has requested to enter room {}", newOccupantJid, roomJid);
           
            if(room.isInRoom(nick)) {
                // user with this nick is already in room
                return createPresenceErrorStanza(roomJid, newOccupantJid, stanza.getID(), "cancel", "conflict");
            }
           
            // check password if password protected
            if(room.isRoomType(RoomType.PasswordProtected)) {
                X x = X.fromStanza(stanza);
                String password = null;
                if(x != null) {
                    password = x.getPasswordValue();
                }
               
                if(password == null || !password.equals(room.getPassword())) {
                    // password missing or not matching
                    return createPresenceErrorStanza(roomJid, newOccupantJid, stanza.getID(), "auth", "not-authorized");
                }
            }
           
            Occupant newOccupant = room.addOccupant(newOccupantJid, nick);
            if(newOccupant == null) {
                // outcast
                return createPresenceErrorStanza(roomJid, newOccupantJid, stanza.getID(), "auth", "forbidden");
            }
            if(room.isRoomType(RoomType.MembersOnly) && newOccupant.getAffiliation() == Affiliation.None) {
                // non-member can not enter members only room
                return createPresenceErrorStanza(roomJid, newOccupantJid, stanza.getID(), "auth", "registration-required");
            }
           
            // relay presence of all existing room occupants to the now joined occupant
View Full Code Here

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

            Entity occupantJid, String nick, ServerRuntimeContext serverRuntimeContext) {
        Room room = conference.findRoom(roomJid);
       
        // room must exist, or we do nothing
        if(room != null) {
            Occupant exitingOccupant = room.findOccupantByJID(occupantJid);
           
            // user must by in room, or we do nothing
            if(exitingOccupant != null) {
                Set<Occupant> allOccupants = room.getOccupants();
               
View Full Code Here

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

                // might be an items request on a room
                Room room = conference.findRoom(request.getTo().getBareJID());
                if (room != null) {
                    if (request.getTo().getResource() != null) {
                        // request for an occupant
                        Occupant occupant = room.findOccupantByNick(request.getTo().getResource());
                        // request for occupant, relay
                        if (occupant != null) {
                            relayDiscoStanza(occupant.getJid(), request, NamespaceURIs.XEP0030_SERVICE_DISCOVERY_INFO);
                        }
                    } else {
                        return room.getInfosFor(request);
                    }
                }
View Full Code Here

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

            // might be an items request on a room
            Room room = conference.findRoom(to.getBareJID());
            if (room != null) {
                if (to.getResource() != null) {
                    // request for an occupant
                    Occupant occupant = room.findOccupantByNick(to.getResource());
                    // request for occupant, relay
                    if (occupant != null) {
                        relayDiscoStanza(occupant.getJid(), request, NamespaceURIs.XEP0030_SERVICE_DISCOVERY_ITEMS);
                    }
                } else {
                    return room.getItemsFor(request);
                }
            }
View Full Code Here

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

        room.addOccupant(OCCUPANT2_JID, "Nick2");

        assertNull(exitRoom(OCCUPANT1_JID, ROOM1_JID_WITH_NICK));

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

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

*/
public class GrantVoiceTestCase extends AbstractMUCHandlerTestCase {

    public void testGrantVoice() throws Exception {
        Room room = conference.findOrCreateRoom(ROOM2_JID, "Room 2");
        Occupant occ1 = room.addOccupant(OCCUPANT1_JID, "nick");
        occ1.setRole(Role.Moderator);
        room.getAffiliations().add(OCCUPANT1_JID, Affiliation.Member);
       
        Occupant occ2 = room.addOccupant(OCCUPANT2_JID, "Nick 2");
        occ2.setRole(Role.Visitor);

        // send message to room
        IQStanza result = (IQStanza) IQStanza.getWrapper(sendIq(OCCUPANT1_JID, ROOM2_JID, SET, "id1",
                NamespaceURIs.XEP0045_MUC_ADMIN, new IqAdminItem("Nick 2", Role.Participant)));
       
View Full Code Here

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

    public void testRevokeOwnershipByNick() throws Exception {
        Room room = conference.findOrCreateRoom(ROOM2_JID, "Room 2", RoomType.MembersOnly);
        room.getAffiliations().add(OCCUPANT1_JID, Affiliation.Owner);
       
        Occupant occ1 = room.addOccupant(OCCUPANT1_JID, "nick");
        occ1.setRole(Role.Moderator);
       
        room.getAffiliations().add(OCCUPANT2_JID, Affiliation.Owner);
        Occupant occ2 = room.addOccupant(OCCUPANT2_JID, "Nick 2");
        occ2.setRole(Role.Visitor);

        // send message to room
        IQStanza result = (IQStanza) IQStanza.getWrapper(sendIq(OCCUPANT1_JID, ROOM2_JID, SET, "id1",
                NamespaceURIs.XEP0045_MUC_ADMIN, new IqAdminItem("Nick 2", Affiliation.Admin)));
        assertIqResultStanza(ROOM2_JID, OCCUPANT1_JID, "id1", result);
View Full Code Here

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

    }

    // Test granting membership for a user which is not currently in the room
    public void testRevokeMembershipByJid() throws Exception {
        Room room = conference.findOrCreateRoom(ROOM2_JID, "Room 2");
        Occupant occ1 = room.addOccupant(OCCUPANT1_JID, "nick");
        occ1.setRole(Role.Moderator);
        room.getAffiliations().add(OCCUPANT1_JID, Affiliation.Owner);
       
        room.getAffiliations().add(OCCUPANT2_JID, Affiliation.Owner);
       
        // send message to room
View Full Code Here

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

                null, new MucUserItem(OCCUPANT2_JID, null, Affiliation.Admin, Role.None), occupant1Queue.getNext());
    }

    public void testNonOwner() throws Exception {
        Room room = conference.findOrCreateRoom(ROOM2_JID, "Room 2");
        Occupant occupant1 = room.addOccupant(OCCUPANT1_JID, "nick");
        occupant1.setRole(Role.Moderator);
        room.getAffiliations().add(OCCUPANT1_JID, Affiliation.Admin);

        room.addOccupant(OCCUPANT2_JID, "Nick 2");
        room.getAffiliations().add(OCCUPANT2_JID, Affiliation.Owner);
       
View Full Code Here

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

    public void testRevokeOwnershipByNick() throws Exception {
        Room room = conference.findOrCreateRoom(ROOM2_JID, "Room 2", RoomType.MembersOnly);
        room.getAffiliations().add(OCCUPANT1_JID, Affiliation.Owner);
       
        Occupant occ1 = room.addOccupant(OCCUPANT1_JID, "nick");
        occ1.setRole(Role.Moderator);
       
        room.getAffiliations().add(OCCUPANT2_JID, Affiliation.Admin);
        Occupant occ2 = room.addOccupant(OCCUPANT2_JID, "Nick 2");
        occ2.setRole(Role.Visitor);

        // send message to room
        IQStanza result = (IQStanza) IQStanza.getWrapper(sendIq(OCCUPANT1_JID, ROOM2_JID, SET, "id1",
                NamespaceURIs.XEP0045_MUC_ADMIN, new IqAdminItem("Nick 2", Affiliation.Member)));
        assertIqResultStanza(ROOM2_JID, OCCUPANT1_JID, "id1", result);
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.