mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 22:12:05 +01:00
Jingle Small App Demo
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7622 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
02b6924b99
commit
8ab9f55da4
1 changed files with 38 additions and 36 deletions
|
@ -1,3 +1,22 @@
|
||||||
|
/**
|
||||||
|
* $RCSfile$
|
||||||
|
* $Revision: $
|
||||||
|
* $Date: 28/12/2006
|
||||||
|
* <p/>
|
||||||
|
* Copyright 2003-2006 Jive Software.
|
||||||
|
* <p/>
|
||||||
|
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p/>
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* <p/>
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.mediaimpl.jmf;
|
package org.jivesoftware.smackx.jingle.mediaimpl.jmf;
|
||||||
|
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
|
@ -7,32 +26,14 @@ import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.JingleSessionRequest;
|
import org.jivesoftware.smackx.jingle.JingleSessionRequest;
|
||||||
import org.jivesoftware.smackx.jingle.OutgoingJingleSession;
|
import org.jivesoftware.smackx.jingle.OutgoingJingleSession;
|
||||||
import org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener;
|
import org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener;
|
||||||
import org.jivesoftware.smackx.jingle.nat.BridgedTransportManager;
|
import org.jivesoftware.smackx.jingle.nat.*;
|
||||||
import org.jivesoftware.smackx.jingle.nat.JingleTransportManager;
|
|
||||||
import org.jivesoftware.smackx.jingle.nat.RTPBridge;
|
|
||||||
import org.jivesoftware.smackx.jingle.nat.STUNTransportManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $RCSfile$
|
* Jingle Demo Application. It register in a XMPP Server and let users place calls using a full JID and auto-receive calls.
|
||||||
* $Revision: $
|
* Parameters: Server User Pass.
|
||||||
* $Date: 28/12/2006
|
|
||||||
*
|
|
||||||
* Copyright 2003-2006 Jive Software.
|
|
||||||
*
|
|
||||||
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
public class Demo extends JFrame {
|
public class Demo extends JFrame {
|
||||||
|
|
||||||
|
@ -60,21 +61,16 @@ public class Demo extends JFrame {
|
||||||
xmppConnection.connect();
|
xmppConnection.connect();
|
||||||
xmppConnection.login(user, pass);
|
xmppConnection.login(user, pass);
|
||||||
initialize();
|
initialize();
|
||||||
} catch (XMPPException e) {
|
}
|
||||||
|
catch (XMPPException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
if (RTPBridge.serviceAvailable(xmppConnection))
|
ICETransportManager icetm0 = new ICETransportManager(xmppConnection, "jivesoftware.com", 3478);
|
||||||
transportManager = new BridgedTransportManager(xmppConnection);
|
jm = new JingleManager(xmppConnection, icetm0, new JmfMediaManager());
|
||||||
else
|
jm.addCreationListener(icetm0);
|
||||||
transportManager = new STUNTransportManager();
|
|
||||||
|
|
||||||
jm = new JingleManager(xmppConnection, transportManager, new JmfMediaManager());
|
|
||||||
|
|
||||||
if (transportManager instanceof BridgedTransportManager)
|
|
||||||
jm.addCreationListener((BridgedTransportManager) transportManager);
|
|
||||||
|
|
||||||
jm.addJingleSessionRequestListener(new JingleSessionRequestListener() {
|
jm.addJingleSessionRequestListener(new JingleSessionRequestListener() {
|
||||||
public void sessionRequested(JingleSessionRequest request) {
|
public void sessionRequested(JingleSessionRequest request) {
|
||||||
|
@ -109,7 +105,9 @@ public class Demo extends JFrame {
|
||||||
if (outgoing != null) return;
|
if (outgoing != null) return;
|
||||||
try {
|
try {
|
||||||
outgoing = jm.createOutgoingJingleSession(jid.getText());
|
outgoing = jm.createOutgoingJingleSession(jid.getText());
|
||||||
} catch (XMPPException e1) {
|
outgoing.start();
|
||||||
|
}
|
||||||
|
catch (XMPPException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,17 +118,21 @@ public class Demo extends JFrame {
|
||||||
if (outgoing != null)
|
if (outgoing != null)
|
||||||
try {
|
try {
|
||||||
outgoing.terminate();
|
outgoing.terminate();
|
||||||
} catch (XMPPException e1) {
|
}
|
||||||
|
catch (XMPPException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
} finally {
|
}
|
||||||
|
finally {
|
||||||
outgoing = null;
|
outgoing = null;
|
||||||
}
|
}
|
||||||
if (incoming != null)
|
if (incoming != null)
|
||||||
try {
|
try {
|
||||||
incoming.terminate();
|
incoming.terminate();
|
||||||
} catch (XMPPException e1) {
|
}
|
||||||
|
catch (XMPPException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
} finally {
|
}
|
||||||
|
finally {
|
||||||
incoming = null;
|
incoming = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue