Search in sources :

Example 1 with JingleSessionRequestListener

use of org.jivesoftware.smackx.jingleold.listeners.JingleSessionRequestListener in project Smack by igniterealtime.

the class JingleManager method initJingleSessionRequestListeners.

/**
     * Register the listenerJingles, waiting for a Jingle stanza(/packet) that tries to
     * establish a new session.
     */
private void initJingleSessionRequestListeners() {
    StanzaFilter initRequestFilter = new StanzaFilter() {

        // Return true if we accept this packet
        @Override
        public boolean accept(Stanza pin) {
            if (pin instanceof IQ) {
                IQ iq = (IQ) pin;
                if (iq.getType().equals(IQ.Type.set)) {
                    if (iq instanceof Jingle) {
                        Jingle jin = (Jingle) pin;
                        if (jin.getAction().equals(JingleActionEnum.SESSION_INITIATE)) {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
    };
    jingleSessionRequestListeners = new ArrayList<JingleSessionRequestListener>();
    // Start a packet listener for session initiation requests
    connection.addAsyncStanzaListener(new StanzaListener() {

        @Override
        public void processStanza(Stanza packet) {
            triggerSessionRequested((Jingle) packet);
        }
    }, initRequestFilter);
}
Also used : Jingle(org.jivesoftware.smackx.jingleold.packet.Jingle) StanzaFilter(org.jivesoftware.smack.filter.StanzaFilter) Stanza(org.jivesoftware.smack.packet.Stanza) IQ(org.jivesoftware.smack.packet.IQ) StanzaListener(org.jivesoftware.smack.StanzaListener) JingleSessionRequestListener(org.jivesoftware.smackx.jingleold.listeners.JingleSessionRequestListener)

Aggregations

StanzaListener (org.jivesoftware.smack.StanzaListener)1 StanzaFilter (org.jivesoftware.smack.filter.StanzaFilter)1 IQ (org.jivesoftware.smack.packet.IQ)1 Stanza (org.jivesoftware.smack.packet.Stanza)1 JingleSessionRequestListener (org.jivesoftware.smackx.jingleold.listeners.JingleSessionRequestListener)1 Jingle (org.jivesoftware.smackx.jingleold.packet.Jingle)1