Package org.apache.vysper.xmpp.stanza

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


     * @param condition the error condition
     */
    private void error(BoshRequest br, String condition) {
        requestsWindow.put(br.getRid(), br);
        BoshRequest req = requestsWindow.remove(requestsWindow.firstKey());
        Stanza body = boshHandler.getTerminateResponse();
        body = boshHandler.addAttribute(body, "condition", condition);
        BoshResponse boshResponse = getBoshResponse(body, null);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("BOSH writing response: {}", new String(boshResponse.getContent()));
        }
View Full Code Here


     */
    synchronized public void close() {
        // respond to all the queued HTTP requests with termination responses
        while (!requestsWindow.isEmpty()) {
            BoshRequest req = requestsWindow.remove(requestsWindow.firstKey());
            Stanza body = boshHandler.getTerminateResponse();
            BoshResponse boshResponse = getBoshResponse(body, null);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("BOSH writing response: {}", new String(boshResponse.getContent()));
            }
            Continuation continuation = ContinuationSupport.getContinuation(req.getHttpServletRequest());
View Full Code Here

            return;
        }
       
        // If there are delayed responses waiting to be sent to the BOSH client, then we wrap them all in
        // a <body/> element and send them as a HTTP response to the current HTTP request.
        Stanza delayedResponse;
        Stanza mergedResponse = null;
        while ((delayedResponse = delayedResponseQueue.poll()) != null) {
            mergedResponse = boshHandler.mergeResponses(mergedResponse, delayedResponse);
        }
        if (mergedResponse != null) {
            write0(mergedResponse);
View Full Code Here

            write0(boshHandler.getEmptyResponse());
        }
    }
   
    private void sendBrokenConnectionReport(long report, long delta) {
        Stanza body = boshHandler.getTerminateResponse();
        body = boshHandler.addAttribute(body, "report", Long.toString(report));
        body = boshHandler.addAttribute(body, "time", Long.toString(delta));
        write0(body);
    }
View Full Code Here

        session.write0(getTerminateResponse());
        session.close();
    }

    private void processStanza(BoshBackedSessionContext session, XMLElement element) {
        Stanza stanza;
        if (element instanceof Stanza) {
            stanza = (Stanza) element;
        } else {
            stanza = new Stanza(element.getNamespaceURI(), element.getName(), element.getNamespacePrefix(),
                    element.getAttributes(), element.getInnerFragments());
        }
        serverRuntimeContext.getStanzaProcessor().processStanza(serverRuntimeContext, session, stanza,
                session.getStateHolder());
    }
View Full Code Here

       
        // adding the ack attribute here is needed because when responding to o request with the same RID (as is the case here)
        // the ack would not be included on BoshBackedSessionContext#write0, but this first ack is required.
        body.addAttribute("ack", Long.toString(session.getHighestReadRid()));

        Stanza features = new ServerResponses().getFeaturesForAuthentication(serverRuntimeContext.getServerFeatures()
                .getAuthenticationMethods());
        body.addPreparedElement(features);
        return body.build();
    }
View Full Code Here

        }
        return body.build();
    }
   
    private Stanza getRestartResponse() {
        Stanza features = new ServerResponses().getFeaturesForSession();
        return wrapStanza(features);
    }
View Full Code Here

       
        //
        // check presence broadcasts to resources of same session (self, interested & available)
        //
       
        Stanza initiatorNotification = initiatingUser.getNextStanza();
        assertNotNull(initiatorNotification);
        assertTrue(checkPresence(initiatorNotification, null, initiatingUser.getEntityFQ(), showValue));
        assertTrue(initiatorNotification.getVerifier().toAttributeEquals(initiatingUser.getEntityFQ().getFullQualifiedName()));
       
        Stanza availableResourceNotification = anotherAvailableUser.getNextStanza();
        assertNotNull(availableResourceNotification);
        assertTrue(checkPresence(availableResourceNotification, null, initiatingUser.getEntityFQ(), showValue));
        assertTrue(availableResourceNotification.getVerifier().toAttributeEquals(anotherAvailableUser.getEntityFQ().getFullQualifiedName()));
        assertNull(anotherAvailableUser.getNextStanza()); // no more stanzas
       
        Stanza interestedResourceNotification = anotherInterestedUser.getNextStanza();
        assertNotNull(interestedResourceNotification);
        assertTrue(checkPresence(interestedResourceNotification, null, initiatingUser.getEntityFQ(), showValue));
        assertTrue(interestedResourceNotification.getVerifier().toAttributeEquals(initiatingUser.getEntity().getFullQualifiedName() + "/" + anotherInterestedUser.getBoundResourceId()));
        assertNull(anotherInterestedUser.getNextStanza()); // no more stanzas
       
        assertNull(anotherInterestedNotAvailUser.getNextStanza()); // no stanza at all

        //
View Full Code Here

    private void assertStanzas(List<Stanza> stanzas, int expectedSize) throws Exception {
        assertEquals(expectedSize, stanzas.size());

        if(expectedSize > 0) {
            for(int i = 0; i<expectedSize - 1; i++) {
                Stanza stanza = stanzas.get(i);
                assertStanza(stanza, BODY + (DiscussionHistory.DEFAULT_HISTORY_SIZE - expectedSize + 2 + i), null);
            }

            // then check subject message
            assertStanza(stanzas.get(expectedSize - 1), null, SUBJECT);
View Full Code Here

        }
        if(x != null) {
            stanzaBuilder.addPreparedElement(x);
        }

        Stanza messageStanza = stanzaBuilder.build();
        ResponseStanzaContainer container = handler.execute(messageStanza,
                sessionContext.getServerRuntimeContext(), true, sessionContext,
                null);
        if (container != null) {
            return container.getResponseStanza();
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.