Java 类org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener 实例源码

项目:java-bells    文件:JingleManager.java   
/**
 * Activates the listenerJingles on a Jingle session request.
 *
 * @param initJin the packet that must be passed to the jingleSessionRequestListener.
 */
void triggerSessionRequested(Jingle initJin) {

    JingleSessionRequestListener[] jingleSessionRequestListeners = null;

    // Make a synchronized copy of the listenerJingles
    synchronized (this.jingleSessionRequestListeners) {
        jingleSessionRequestListeners = new JingleSessionRequestListener[this.jingleSessionRequestListeners.size()];
        this.jingleSessionRequestListeners.toArray(jingleSessionRequestListeners);
    }

    // ... and let them know of the event
    JingleSessionRequest request = new JingleSessionRequest(this, initJin);
    for (int i = 0; i < jingleSessionRequestListeners.length; i++) {
        jingleSessionRequestListeners[i].sessionRequested(request);
    }
}
项目:spark-svn-mirror    文件:JinglePlugin.java   
/**
 * Adds Jingle and ChatRoom listeners.
 */
private void addListeners() {

    if (jingleManager == null) {
        if (readyToConnect)
        {
        Log.error("Unable to resolve Jingle Connection (Host: "+stunServer+" Port: "+stunPort+")");
        }
        return;

    }


    // Listen in for new incoming Jingle requests.
    jingleManager.addJingleSessionRequestListener(new JingleSessionRequestListener() {
        public void sessionRequested(final JingleSessionRequest request) {              
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    incomingJingleSession(request);
                }
            });
        }
    });
}
项目:Smack    文件:Demo.java   
public void initialize() {
        ICETransportManager icetm0 = new ICETransportManager(xmppConnection, "10.47.47.53", 3478);
        List<JingleMediaManager> mediaManagers = new ArrayList<JingleMediaManager>();
        //mediaManagers.add(new JmfMediaManager(icetm0));
        mediaManagers.add(new SpeexMediaManager(icetm0));
        mediaManagers.add(new ScreenShareMediaManager(icetm0));
        jm = new JingleManager(xmppConnection, mediaManagers);
        jm.addCreationListener(icetm0);

        jm.addJingleSessionRequestListener(new JingleSessionRequestListener() {
            public void sessionRequested(JingleSessionRequest request) {

//                if (incoming != null)
//                    return;

                try {
                    // Accept the call
                    incoming = request.accept();

                    // Start the call
                    incoming.startIncoming();
                }
                catch (XMPPException e) {
                    e.printStackTrace();
                }

            }
        });
        createGUI();
    }
项目:java-bells    文件:Demo.java   
public void initialize() {
        ICETransportManager icetm0 = new ICETransportManager(xmppConnection, "10.47.47.53", 3478);
        List<JingleMediaManager> mediaManagers = new ArrayList<JingleMediaManager>();
        //mediaManagers.add(new JmfMediaManager(icetm0));
        mediaManagers.add(new SpeexMediaManager(icetm0));
        mediaManagers.add(new ScreenShareMediaManager(icetm0));
        jm = new JingleManager(xmppConnection, mediaManagers);
        jm.addCreationListener(icetm0);

        jm.addJingleSessionRequestListener(new JingleSessionRequestListener() {
            public void sessionRequested(JingleSessionRequest request) {

//                if (incoming != null)
//                    return;

                try {
                    // Accept the call
                    incoming = request.accept();

                    // Start the call
                    incoming.startIncoming();
                }
                catch (XMPPException e) {
                    e.printStackTrace();
                }

            }
        });
        createGUI();
    }
项目:java-bells    文件:JingleManager.java   
/**
* Add a Jingle session request listenerJingle to listen to incoming session
* requests.
*
* @param jingleSessionRequestListener an implemented JingleSessionRequestListener
* @see #removeJingleSessionRequestListener(JingleSessionRequestListener)
* @see JingleListener
*/
public synchronized void addJingleSessionRequestListener(final JingleSessionRequestListener jingleSessionRequestListener) {
    if (jingleSessionRequestListener != null) {
        if (jingleSessionRequestListeners == null) {
            initJingleSessionRequestListeners();
        }
        synchronized (jingleSessionRequestListeners) {
            jingleSessionRequestListeners.add(jingleSessionRequestListener);
        }
    }
}
项目:java-bells    文件:JingleManager.java   
/**
 * Removes a Jingle session listenerJingle.
 *
 * @param jingleSessionRequestListener The jingle session jingleSessionRequestListener to be removed
 * @see #addJingleSessionRequestListener(JingleSessionRequestListener)
 * @see JingleListener
 */
public void removeJingleSessionRequestListener(JingleSessionRequestListener jingleSessionRequestListener) {
    if (jingleSessionRequestListeners == null) {
        return;
    }
    synchronized (jingleSessionRequestListeners) {
        jingleSessionRequestListeners.remove(jingleSessionRequestListener);
    }
}
项目:java-bells    文件:JingleManager.java   
/**
 * Register the listenerJingles, waiting for a Jingle packet that tries to
 * establish a new session.
 */
private void initJingleSessionRequestListeners() {
    PacketFilter initRequestFilter = new PacketFilter() {
        // Return true if we accept this packet
        public boolean accept(Packet 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.addPacketListener(new PacketListener() {
        public void processPacket(Packet packet) {
            triggerSessionRequested((Jingle) packet);
        }
    }, initRequestFilter);
}
项目:Smack    文件:JingleManagerTest.java   
/**
 * High level API test. This is a simple test to use with an XMPP client and
 * check if the client receives the message 1. User_1 will send an
 * invitation to user_2.
 */
public void testSendSimpleMessage() {

    resetCounter();

    try {
        FixedResolver tr0 = new FixedResolver("127.0.0.1", 54222);
        FixedTransportManager ftm0 = new FixedTransportManager(tr0);
        TestMediaManager tmm0 = new TestMediaManager(ftm0);
        tmm0.setPayloads(getTestPayloads1());
        List<JingleMediaManager> trl0 = new ArrayList<JingleMediaManager>();
        trl0.add(tmm0);

        FixedResolver tr1 = new FixedResolver("127.0.0.1", 54567);
        FixedTransportManager ftm1 = new FixedTransportManager(tr1);
        TestMediaManager tmm1 = new TestMediaManager(ftm1);
        tmm1.setPayloads(getTestPayloads1());
        List<JingleMediaManager> trl1 = new ArrayList<JingleMediaManager>();
        trl1.add(tmm1);

        JingleManager man0 = new JingleManager(getConnection(0), trl0);
        JingleManager man1 = new JingleManager(getConnection(1), trl1);

        // Session 1 waits for connections
        man1.addJingleSessionRequestListener(new JingleSessionRequestListener() {
            /**
             * Called when a new session request is detected
             */
            public void sessionRequested(final JingleSessionRequest request) {
                incCounter();
                System.out.println("Session request detected, from " + request.getFrom());
            }
        });

        // Session 0 starts a request
        System.out.println("Starting session request, to " + getFullJID(1) + "...");
        JingleSession session0 = man0.createOutgoingJingleSession(getFullJID(1));
        session0.startOutgoing();

        Thread.sleep(5000);

        assertTrue(valCounter() > 0);

    } catch (Exception e) {
        e.printStackTrace();
        fail("An error occured with Jingle");
    }
}