Package org.apache.vysper.xmpp.modules.extension.xep0045_muc.stanzas

Examples of org.apache.vysper.xmpp.modules.extension.xep0045_muc.stanzas.X


        assertEquals(expectedBody, msgStanza.getBody(null));
        assertEquals(expectedSubject, msgStanza.getSubject(null));

        if(expectedX != null) {
            X actualX = X.fromStanza(stanza);
            assertEquals(expectedX, actualX);
        }
    }
View Full Code Here


                        } else {
                            // user must be occupant to send direct message
                            return createMessageErrorStanza(room.getJID(), from, stanza.getID(), StanzaErrorType.MODIFY, StanzaErrorCondition.NOT_ACCEPTABLE, stanza);
                        }
                    } else {
                        X x = X.fromStanza(stanza);
                        if(x != null && x.getInvite() != null) {
                            if(sendingOccupant != null) {
                                // invite, forward modified invite
                                try {
                                    Stanza invite = MUCHandlerHelper.createInviteMessageStanza(stanza, room.getPassword());
                                    relayStanza(invite.getTo(), invite, serverRuntimeContext);
                                } catch (EntityFormatException e) {
                                    // invalid format of invite element
                                    return createMessageErrorStanza(room.getJID(), from, stanza.getID(), StanzaErrorType.MODIFY, StanzaErrorCondition.JID_MALFORMED, stanza);
                                }
                            } else {
                                // user must be occupant to send invite
                                return createMessageErrorStanza(room.getJID(), from, stanza.getID(), StanzaErrorType.MODIFY, StanzaErrorCondition.NOT_ACCEPTABLE, stanza);
                            }
                        } else if(x != null && x.getDecline() != null) {
                            // invite, forward modified decline
                            try {
                                Stanza decline = MUCHandlerHelper.createDeclineMessageStanza(stanza);
                                relayStanza(decline.getTo(), decline, serverRuntimeContext);
                            } catch (EntityFormatException e) {
View Full Code Here

        room.setPassword("secret");
        room.addOccupant(OCCUPANT1_JID, "nick");

        Invite invite = new Invite(null, OCCUPANT2_JID, reason);
        // send message to occupant 1
        assertNull(sendMessage(OCCUPANT1_JID, ROOM1_JID, null, null, new X(invite), null));

        X expectedX = new X(new Invite(OCCUPANT1_JID, null, reason), new Password("secret"));
        // verify stanzas to existing occupants on the exiting user
        assertMessageStanza(ROOM1_JID, OCCUPANT2_JID, null, null, null, expectedX,
                occupant2Queue.getNext());
        assertNull(occupant1Queue.getNext());
    }
View Full Code Here

        Room room = conference.findOrCreateRoom(ROOM1_JID, "Room 1");
        room.addOccupant(OCCUPANT2_JID, "nick");

        Decline decline = new Decline(null, OCCUPANT2_JID, reason);
        // send message to occupant 1
        Stanza error = sendMessage(OCCUPANT1_JID, ROOM1_JID, null, null, new X(decline), null);
        assertNull(error);

        X expectedX = new X(new Decline(OCCUPANT1_JID, null, reason));
        // verify stanzas to existing occupants on the exiting user
        assertMessageStanza(ROOM1_JID, OCCUPANT2_JID, null, null, null, expectedX,
                occupant2Queue.getNext());
        assertNull(occupant1Queue.getNext());
    }
View Full Code Here

              xInnerElms.add(new Password(password));
            }
            if(history != null) {
              xInnerElms.add(history);
            }
            stanzaBuilder.addPreparedElement(new X(xInnerElms));
        }
        Stanza presenceStanza = stanzaBuilder.build();
        ResponseStanzaContainer container = handler.execute(presenceStanza, userSessionContext.getServerRuntimeContext(), true, userSessionContext, null);
        if(container != null) {
            return container.getResponseStanza();
View Full Code Here

    private Stanza createPresenceErrorStanza(Entity from, Entity to, String id, String type, String errorName) {
        // "Note: If an error occurs in relation to joining a room, the service SHOULD include
        // the MUC child element (i.e., <x xmlns='http://jabber.org/protocol/muc'/>) in the
        // <presence/> stanza of type "error"."

        return MUCHandlerHelper.createErrorStanza("presence", from, to, id, type, errorName, Arrays.asList((XMLElement)new X()));
    }
View Full Code Here

                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");
View Full Code Here

        }
       
        Entity roomAndOccupantNick = new EntityImpl(room.getJID(), existingOccupant.getName());
        StanzaBuilder builder = StanzaBuilder.createPresenceStanza(roomAndOccupantNick, newOccupant.getJid(), null, null, null, null);
       
        builder.addPreparedElement(new X(NamespaceURIs.XEP0045_MUC_USER,
                new Item(null, null, existingOccupant.getAffiliation(), existingOccupant.getRole())));

       
        logger.debug("Room presence from {} sent to {}", newOccupant, roomAndOccupantNick);
        relayStanza(newOccupant.getJid(), builder.build(), serverRuntimeContext);
View Full Code Here

            }
           
            // send status to indicate that this is the users own presence
            inner.add(new Status(StatusCode.OWN_PRESENCE));
        }
        builder.addPreparedElement(new X(NamespaceURIs.XEP0045_MUC_USER, inner));

        logger.debug("Room presence from {} sent to {}", roomAndNewUserNick, existingOccupant);
        relayStanza(existingOccupant.getJid(), builder.build(), serverRuntimeContext);
    }
View Full Code Here

       
        if(receiver.getJid().equals(changer.getJid())) {
            // send status to indicate that this is the users own presence
            inner.add(new Status(StatusCode.OWN_PRESENCE));
        }
        builder.addPreparedElement(new X(NamespaceURIs.XEP0045_MUC_USER, inner));

        logger.debug("Room presence from {} sent to {}", roomAndOldNick, receiver);
        relayStanza(receiver.getJid(), builder.build(), serverRuntimeContext);
    }
View Full Code Here

TOP

Related Classes of org.apache.vysper.xmpp.modules.extension.xep0045_muc.stanzas.X

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.