Package org.apache.vysper.xmpp.stanza

Examples of org.apache.vysper.xmpp.stanza.StanzaBuilder


        return stanzaBuilder.build();
    }

    public Stanza getAuthAborted() {

        StanzaBuilder stanzaBuilder = new StanzaBuilder("aborted", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_TLS);
        return stanzaBuilder.build();
    }
View Full Code Here


        return createInviteDeclineMessageStanza(original, decline.getTo(), null, newDecline);
    }

   
    public static Stanza createInviteDeclineMessageStanza(Stanza original, Entity to, String password, AbstractInviteDecline invdec) throws EntityFormatException {
        StanzaBuilder builder = StanzaBuilder.createMessageStanza(original.getTo(), to, null, null);
        List<XMLElement> inner = new ArrayList<XMLElement>();
        inner.add(invdec);
        if(password != null) {
            inner.add(new Password(password));
        }
       
        X newX = new X(NamespaceURIs.XEP0045_MUC_USER, inner);
        builder.addPreparedElement(newX);
        return builder.build();
    }
View Full Code Here

        // add occupants to the room
        Room room = conference.findOrCreateRoom(ROOM1_JID, "Room 1");
        room.addOccupant(OCCUPANT1_JID, "nick");
        room.addOccupant(OCCUPANT2_JID, "Nick 2");

        StanzaBuilder request = StanzaBuilder.createIQStanza(OCCUPANT1_JID, new EntityImpl(ROOM1_JID, "Nick 2"), IQStanzaType.GET, "123");
        request.startInnerElement("query", getNamespace()).endInnerElement();

        // send message to room
        sendDisco(request.build());

        assertNull(occupant1Queue.getNext());
        Stanza stanza = occupant2Queue.getNext();
        assertNotNull(stanza);
        assertEquals(OCCUPANT1_JID, stanza.getFrom());
View Full Code Here

//             from='wiccarocks@shakespeare.lit/laptop'
//             stamp='2002-10-13T23:58:43Z'/>
//        </message>
       
        Entity roomJid = message.getTo();
        StanzaBuilder builder = StanzaBuilder.createForward(message, new EntityImpl(roomJid, fromNick), receiver.getJid());

        Entity delayFrom;
        if(includeJid) {
            delayFrom = message.getFrom();
        } else {
            delayFrom = new EntityImpl(roomJid, fromNick);
        }
        Delay delay = new Delay(delayFrom, timestamp);
        builder.addPreparedElement(delay);
       
        return builder.build();
    }
View Full Code Here

    private static final Entity ROOM_JID = TestUtil.parseUnchecked("room@vysper.org");

    private static final Occupant FROM_OCCUPANT = new Occupant(FROM, NICK, Affiliation.None, Role.Visitor);
   
    public void testSubjectMessage() {
        StanzaBuilder builder = StanzaBuilder.createMessageStanza(FROM, ROOM_JID, null, null);
        builder.startInnerElement("subject").addText(SUBJECT).endInnerElement();
       
        DiscussionMessage item = new DiscussionMessage(builder.build(), FROM_OCCUPANT, TIMESTAMP);
        assertEquals(NICK, item.getNick());
        assertEquals(TIMESTAMP, item.getTimestamp());
        assertFalse(item.hasBody());
        assertTrue(item.hasSubject());
    }
View Full Code Here

        assertTrue(item.hasSubject());
    }
   
   
    public void testBodyMessage() {
        StanzaBuilder builder = StanzaBuilder.createMessageStanza(FROM, ROOM_JID, null, BODY);
       
        DiscussionMessage item = new DiscussionMessage(builder.build(), FROM_OCCUPANT, TIMESTAMP);
        assertEquals(NICK, item.getNick());
        assertEquals(TIMESTAMP, item.getTimestamp());
        assertTrue(item.hasBody());
        assertFalse(item.hasSubject());
    }
View Full Code Here

        assertTrue(item.hasBody());
        assertFalse(item.hasSubject());
    }

    public void testCreateStanza() throws Exception {
        StanzaBuilder builder = StanzaBuilder.createMessageStanza(FROM, ROOM_JID, MessageStanzaType.GROUPCHAT, null, BODY);
        Stanza inStanza = builder.build();
        DiscussionMessage item = new DiscussionMessage(inStanza, FROM_OCCUPANT, TIMESTAMP);
       
        Entity to = TestUtil.parseUnchecked("user2@vysper.org/res");
        Occupant toOccupant = new Occupant(to, "nick 2", Affiliation.None, Role.Visitor);
        MessageStanza outStanza = (MessageStanza) MessageStanza.getWrapper(item.createStanza(toOccupant, true));
View Full Code Here

        if(existingOccupant.getJid().equals(newOccupant.getJid())) {
            return;
        }
       
        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

    }
   
    private void sendNewOccupantPresenceToExisting(Occupant newOccupant, Occupant existingOccupant, Room room, ServerRuntimeContext serverRuntimeContext) {
        Entity roomAndNewUserNick = new EntityImpl(room.getJID(), newOccupant.getName());
       
        StanzaBuilder builder = StanzaBuilder.createPresenceStanza(roomAndNewUserNick, existingOccupant.getJid(), null, null, null, null);
       
        List<XMLElement> inner = new ArrayList<XMLElement>();

       
        // room is non-anonymous or semi-anonmoys and the occupant a moderator, send full user JID
        boolean includeJid = room.getRoomTypes().contains(RoomType.NonAnonymous) ||
            (room.getRoomTypes().contains(RoomType.SemiAnonymous) && existingOccupant.getRole() == Role.Moderator);
        inner.add(new Item(newOccupant, includeJid, false));
       
        if(existingOccupant.getJid().equals(newOccupant.getJid())) {
           
            if(room.getRoomTypes().contains(RoomType.NonAnonymous)) {
                // notify the user that this is a non-anonymous room
                inner.add(new Status(StatusCode.ROOM_NON_ANONYMOUS));
            }
           
            // 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

    }

    private void sendChangeNickUnavailable(Occupant changer, String oldNick, Occupant receiver, Room room, ServerRuntimeContext serverRuntimeContext) {
        Entity roomAndOldNick = new EntityImpl(room.getJID(), oldNick);
       
        StanzaBuilder builder = StanzaBuilder.createPresenceStanza(roomAndOldNick, receiver.getJid(), null,
                PresenceStanzaType.UNAVAILABLE, null, null);
       
        List<XMLElement> inner = new ArrayList<XMLElement>();
       
        boolean includeJid = includeJidInItem(room, receiver);
        inner.add(new Item(changer, includeJid, true));
        inner.add(new Status(StatusCode.NEW_NICK));
       
        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.stanza.StanzaBuilder

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.