Package org.apache.vysper.xmpp.stanza

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


        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


               
                // now add all messages, as long as the predicated are fulfilled
                // first, do this in reverse order so that older messages are filtered out
                for(int i = itemsWithSubject.size() - 1; i > -1; i--) {
                    DiscussionMessage item = itemsWithSubject.get(i);
                    Stanza stanza = item.createStanza(receiver, includeJid);
                    counter++;
   
                    if(secondsLimit != -1 && secondsLimit > item.getTimestamp().getTimeInMillis()) {
                        // too old, break
                        break;
View Full Code Here

        IQHandler infoIQHandler = createDiscoIQHandler();

        StanzaBuilder request = buildRequest();
       
        ResponseStanzaContainer resultStanzaContainer = infoIQHandler.execute(request.build(), serverRuntimeContext, false, new TestSessionContext(serverRuntimeContext, new SessionStateHolder()), null);
        Stanza resultStanza = resultStanzaContainer.getResponseStanza();

        assertEquals("Disco request must not return error", "result", resultStanza.getAttributeValue("type"));
        XMLElement queryElement = resultStanza.getFirstInnerElement();
       
        assertResponse(queryElement);
    }
View Full Code Here

                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();
        // first stanza should be room presence
        assertNotNull(stanza);
        assertEquals("presence", stanza.getName());
       
        stanza = occupant1Queue.getNext();
        // here we get the message history
        assertNotNull(stanza);
        assertEquals("message", stanza.getName());
        MessageStanza msgStanza = (MessageStanza) MessageStanza.getWrapper(stanza);
        assertEquals("Body2", msgStanza.getBody(null));

        stanza = occupant1Queue.getNext();
        // first stanza should be room presence
        assertNotNull(stanza);
        assertEquals("message", stanza.getName());
        msgStanza = (MessageStanza) MessageStanza.getWrapper(stanza);
        assertEquals("Body3", msgStanza.getBody(null));
       
        // we only requested two messages
        assertNull(occupant1Queue.getNext());
View Full Code Here

    }
   
    private Stanza exitRoom(Entity occupantJid, Entity roomJid, String status) throws ProtocolException {
        StanzaBuilder stanzaBuilder = StanzaBuilder.createPresenceStanza(occupantJid, roomJid, null, PresenceStanzaType.UNAVAILABLE, null, status);

        Stanza presenceStanza = stanzaBuilder.build();
        ResponseStanzaContainer container = handler.execute(presenceStanza, sessionContext.getServerRuntimeContext(), true, sessionContext, null);
        if(container != null) {
            return container.getResponseStanza();
        } else {
            return null;
View Full Code Here

*/
public class ResponseWriter {

    public static void writeUnsupportedStanzaError(SessionContext sessionContext) {

        Stanza errorStanza = ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.UNSUPPORTED_STANZA_TYPE,
                sessionContext.getXMLLang(),
                "service unavailable at this session state",
                null);
        Stanza streamOpener = new ServerResponses().getStreamOpenerForError(false, sessionContext.getServerJID(), XMPPVersion.VERSION_1_0, errorStanza);

        writeErrorAndClose(sessionContext, streamOpener);
    }
View Full Code Here

     * writes a response in this context from the given emmitter
     * @param sessionContext
     * @param responseStanzaContainer
     */
    public static void writeResponse(SessionContext sessionContext, ResponseStanzaContainer responseStanzaContainer) {
        Stanza responseStanza = responseStanzaContainer.getResponseStanza();
        writeResponse(sessionContext, responseStanza);
    }
View Full Code Here

    public static void writeResponse(SessionContext sessionContext, Stanza responseStanza) {
        sessionContext.getResponseWriter().write(responseStanza);
    }

    public static void handleProtocolError(ProtocolException protocolException, SessionContext sessionContext, Stanza receivedStanza) {
        Stanza errorStanza = null;
        if (protocolException != null) errorStanza = protocolException.getErrorStanza();

        if (errorStanza == null) {
            errorStanza = ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.BAD_FORMAT,
                                                              sessionContext.getXMLLang(),
View Full Code Here

        }
        writeErrorAndClose(sessionContext, errorStanza);
    }

    public void handleUnsupportedStanzaType(SessionContext sessionContext, Stanza receivedStanza) {
        Stanza errorStanza = ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.UNSUPPORTED_STANZA_TYPE,
                                                          sessionContext.getXMLLang(),
                                                          "could not process incoming stanza",
                                                          receivedStanza);
        writeErrorAndClose(sessionContext, errorStanza);
    }
View Full Code Here

                                                          receivedStanza);
        writeErrorAndClose(sessionContext, errorStanza);
    }

    public void handleNotAuthorized(SessionContext sessionContext, Stanza receivedStanza) {
        Stanza errorStanza = ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.NOT_AUTHORIZED,
                                                          sessionContext.getXMLLang(),
                                                          "could not process incoming stanza",
                                                          receivedStanza);
        writeErrorAndClose(sessionContext, errorStanza);
    }
View Full Code Here

TOP

Related Classes of org.apache.vysper.xmpp.stanza.Stanza

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.