Package org.apache.vysper.xmpp.server

Examples of org.apache.vysper.xmpp.server.SessionContext


        logger.debug("session {} is idle", ((SessionContext) ioSession.getAttribute(ATTRIBUTE_VYSPER_SESSION))
                .getSessionId());
    }

    public void exceptionCaught(IoSession ioSession, Throwable throwable) throws Exception {
        SessionContext sessionContext = extractSession(ioSession);

        Stanza errorStanza;
        if(throwable.getCause() != null && throwable.getCause() instanceof SAXParseException) {
            logger.info("Client sent not well-formed XML, closing session: {}", throwable);
            errorStanza = ServerErrorResponses.getStreamError(StreamErrorCondition.XML_NOT_WELL_FORMED,
                    sessionContext.getXMLLang(), "Stanza not well-formed", null);
        } else if(throwable instanceof WriteToClosedSessionException) {
            // ignore
            return;
        } else {
            logger.warn("error caught on transportation layer: {}", throwable);
            errorStanza = ServerErrorResponses.getStreamError(StreamErrorCondition.UNDEFINED_CONDITION,
                    sessionContext.getXMLLang(), "Unknown error", null);

        }
        sessionContext.getResponseWriter().write(errorStanza);
        sessionContext.endSession(SessionContext.SessionTerminationCause.STREAM_ERROR);
    }
View Full Code Here


            return new ResponseStanzaContainerImpl(builder.build());
        } else {
            // acting as a Receiving server
            // getting a response from the Authoritative server
            SessionStateHolder dialbackSessionStateHolder = (SessionStateHolder) sessionContext.getAttribute("DIALBACK_SESSION_STATE_HOLDER");
            SessionContext dialbackSessionContext = (SessionContext) sessionContext.getAttribute("DIALBACK_SESSION_CONTEXT");

//            XMPPServerConnector connector = serverRuntimeContext.getServerConnectorRegistry().getConnectorBySessionId(id);
           
//            if(connector != null) {
//                SessionStateHolder dialbackSessionStateHolder = connector.getSessionStateHolder();
//                SessionContext dialbackSessionContext = connector.getSessionContext();
   
               
                Entity otherServer = sessionContext.getInitiatingEntity();
                String resultType = "invalid";
                // dialbackSessionContext must be non-null or someone is trying to send this stanza in the wrong state
                if("valid".equals(type)) {
                    dialbackSessionStateHolder.setState(SessionState.AUTHENTICATED);
                    dialbackSessionContext.setInitiatingEntity(otherServer);
                    resultType = "valid";
                }
               
                // <db:result xmlns:db="jabber:server:dialback" to="xmpp.protocol7.com" from="jabber.org" type="valid"></db:result>
                StanzaBuilder builder = new StanzaBuilder("result", NamespaceURIs.JABBER_SERVER_DIALBACK, "db");
                builder.addAttribute("from", originating.getDomain());
                builder.addAttribute("to", otherServer.getDomain());
                builder.addAttribute("type", resultType);
   
                dialbackSessionContext.getResponseWriter().write(builder.build());
//            }
           
            // close this session as we are now done checking dialback
            sessionContext.endSession(SessionTerminationCause.CLIENT_BYEBYE);
            return null;
View Full Code Here

    public boolean unbindResource(String resourceId) {
        boolean noResourceRemainsForSession = false;
        synchronized (boundResources) {
            synchronized (entityResources) {
                synchronized (sessionResources) {
                    SessionContext sessionContext = getSessionContext(resourceId);

                    // remove from entity's list of resources
                    List<String> resourceListForEntity = getResourceList(sessionContext.getInitiatingEntity());
                    resourceListForEntity.remove(resourceId);
                    if (resourceListForEntity.isEmpty())
                        entityResources.remove(sessionContext.getInitiatingEntity());

                    // remove from session's list of resources
                    List<String> resourceListForSession = sessionResources.get(sessionContext);
                    resourceListForSession.remove(resourceId);
                    noResourceRemainsForSession = resourceListForSession.isEmpty();
View Full Code Here

        return enterRoom(occupantJid, roomJid, null, null, false);
    }

    private Stanza enterRoom(Entity occupantJid, Entity roomJid, String password, History history, boolean oldProtocol)
            throws ProtocolException {
        SessionContext userSessionContext;
        if (occupantJid.equals(OCCUPANT1_JID)) {
            userSessionContext = sessionContext;
        } else {
            userSessionContext = sessionContext2;
        }

        StanzaBuilder stanzaBuilder = StanzaBuilder.createPresenceStanza(occupantJid, roomJid, null, null, null, null);
        if (!oldProtocol) {
            List<XMLElement> xInnerElms = new ArrayList<XMLElement>();
            if (password != null) {
                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();
        } else {
            return null;
View Full Code Here

TOP

Related Classes of org.apache.vysper.xmpp.server.SessionContext

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.