mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-10-05 05:59:32 +02:00
SMACK-279: The XMPPConnection extends the new abstract Connection class
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@11613 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
11a41e79ca
commit
127319a821
|
@ -19,8 +19,9 @@
|
|||
</p>
|
||||
|
||||
<p>
|
||||
The <tt>org.jivesoftware.smack.XMPPConnection</tt> class manages your connection to an XMPP
|
||||
server. Two constructors are available. The first, <tt>XMPPConnection(String)</tt> takes
|
||||
The <tt>org.jivesoftware.smack.Connection</tt> class manages your connection to an XMPP
|
||||
server. The default implementation is the <tt>org.jivesoftware.smack.XMPPConnection</tt>
|
||||
class. Two constructors are mainly used. The first, <tt>XMPPConnection(String)</tt> takes
|
||||
the server name you'd like to connect to as an argument. All default connection settings will
|
||||
be used:
|
||||
<ul>
|
||||
|
@ -62,7 +63,7 @@ ConnectionConfiguration config = new ConnectionConfiguration(<font color="green"
|
|||
config.setCompressionEnabled(true);
|
||||
config.setSASLAuthenticationEnabled(true);
|
||||
|
||||
XMPPConnection connection = new XMPPConnection(config);
|
||||
Connection connection = new XMPPConnection(config);
|
||||
<font color="gray"><i>// Connect to the server</i></font>
|
||||
connection.connect();
|
||||
<font color="gray"><i>// Log into the server</i></font>
|
||||
|
@ -79,7 +80,7 @@ manager will try to immediately reconnect to the server and increase the delay b
|
|||
successive reconnections keep failing.</i>
|
||||
<br>
|
||||
In case you want to force a reconnection while the reconnetion manager is waiting for the next
|
||||
reconnection, you can just use <i>XMPPConnection#connect()</i> and a new attempt will be made.
|
||||
reconnection, you can just use <i>Connection#connect()</i> and a new attempt will be made.
|
||||
If the manual attempt also failed then the reconnection manager will still continue the
|
||||
reconnection job.
|
||||
</p>
|
||||
|
|
|
@ -26,7 +26,7 @@ Debugging mode can be enabled in two different ways:
|
|||
|
||||
<ol>
|
||||
<li>Add the following line of code <b>before</b> creating new connections:<p>
|
||||
<tt>XMPPConnection.DEBUG_ENABLED = true;</tt><p>
|
||||
<tt>Connection.DEBUG_ENABLED = true;</tt><p>
|
||||
|
||||
<li>Set the Java system property <tt>smack.debugEnabled</tt> to true. The
|
||||
system property can be set on the command line such as:<p>
|
||||
|
@ -39,7 +39,7 @@ add the following line to your application before opening new connections:
|
|||
</p>
|
||||
|
||||
<p>
|
||||
<tt>XMPPConnection.DEBUG_ENABLED = false;</tt>
|
||||
<tt>Connection.DEBUG_ENABLED = false;</tt>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
|
@ -34,9 +34,9 @@ discovery request with the information that you previously configured.</p>
|
|||
<b>Usage</b><p>
|
||||
|
||||
In order to configure the supported features by your client you should first obtain the
|
||||
ServiceDiscoveryManager associated with your XMPPConnection. To get your ServiceDiscoveryManager
|
||||
ServiceDiscoveryManager associated with your Connection. To get your ServiceDiscoveryManager
|
||||
send <b>getInstanceFor(connection)</b> to the class <i><b>ServiceDiscoveryManager</b></i> where
|
||||
connection is your XMPPConnection.<br></p>
|
||||
connection is your Connection.<br></p>
|
||||
|
||||
<p>Once you have your ServiceDiscoveryManager you will be able to manage the supported features. To
|
||||
register a new feature send <b>addFeature(feature)</b> to your <i><b>ServiceDiscoveryManager</b></i>
|
||||
|
@ -48,7 +48,7 @@ String that represents the feature to remove.</p>
|
|||
|
||||
In this example we can see how to add and remove supported features: <br>
|
||||
<blockquote>
|
||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my XMPPConnection</font>
|
||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my Connection</font>
|
||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
|
||||
<font color="#3f7f5f">// Register that a new feature is supported by this XMPP entity</font>
|
||||
|
@ -74,7 +74,7 @@ to configure the information providers associated to the items/nodes within the
|
|||
In order to configure the associated nodes within the Smack client you will need to create a
|
||||
NodeInformationProvider and register it with the <i><b>ServiceDiscoveryManager</b></i>. To get
|
||||
your ServiceDiscoveryManager send <b>getInstanceFor(connection)</b> to the class <i><b>ServiceDiscoveryManager</b></i>
|
||||
where connection is your XMPPConnection.<br></p>
|
||||
where connection is your Connection.<br></p>
|
||||
|
||||
<p>Once you have your ServiceDiscoveryManager you will be able to register information providers
|
||||
for the XMPP entity's nodes. To register a new node information provider send <b>setNodeInformationProvider(String node, NodeInformationProvider listener)</b>
|
||||
|
@ -126,7 +126,7 @@ the discovered items.</p>
|
|||
|
||||
In this example we can see how to discover the items associated with an online catalog service: <br>
|
||||
<blockquote>
|
||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my XMPPConnection</font>
|
||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my Connection</font>
|
||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
|
||||
<font color="#3f7f5f">// Get the items of a given XMPP entity</font>
|
||||
|
@ -171,7 +171,7 @@ the discovered information.</p>
|
|||
|
||||
In this example we can see how to discover the information of a conference room: <br>
|
||||
<blockquote>
|
||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my XMPPConnection</font>
|
||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my Connection</font>
|
||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
|
||||
<font color="#3f7f5f">// Get the information of a given XMPP entity</font>
|
||||
|
@ -216,7 +216,7 @@ to publish.</p>
|
|||
|
||||
In this example we can see how to publish new items: <br>
|
||||
<blockquote>
|
||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my XMPPConnection</font>
|
||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my Connection</font>
|
||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
|
||||
<font color="#3f7f5f">// Create a DiscoverItems with the items to publish</font>
|
||||
|
|
|
@ -34,7 +34,7 @@ to enable the user to easily send a file.
|
|||
<b>Usage</b><p>
|
||||
|
||||
In order to send a file you must first construct an instance of the <b><i>FileTransferManager</i></b>
|
||||
class. This class has one constructor with one parameter which is your XMPPConnection.
|
||||
class. This class has one constructor with one parameter which is your Connection.
|
||||
In order to instantiate the manager you should call <i>new FileTransferManager(connection)</i>
|
||||
|
||||
<p>Once you have your <b><i>FileTransferManager</i></b> you will need to create an outgoing
|
||||
|
@ -86,7 +86,7 @@ manager.</p>
|
|||
<b>Usage</b><p>
|
||||
|
||||
In order to recieve a file you must first construct an instance of the <b><i>FileTransferManager</i></b>
|
||||
class. This class has one constructor with one parameter which is your XMPPConnection.
|
||||
class. This class has one constructor with one parameter which is your Connection.
|
||||
In order to instantiate the manager you should call <i>new FileTransferManager(connection)</i>
|
||||
|
||||
<p>Once you have your <b><i>FileTransferManager</i></b> you will need to register a listener
|
||||
|
|
|
@ -75,14 +75,14 @@ You can receive notification requests for the following events: delivered, displ
|
|||
The general idea is to create a new <i>DefaultMessageEventRequestListener</i> that will listen to the event notifications
|
||||
requests and react with custom logic. Then you will have to add the listener to the
|
||||
<i>MessageEventManager</i> that works on
|
||||
the desired <i>XMPPConnection</i>.
|
||||
the desired <i>Connection</i>.
|
||||
<p>Note that <i>DefaultMessageEventRequestListener</i> is a default implementation of the
|
||||
<i>MessageEventRequestListener</i> interface.
|
||||
The class <i>DefaultMessageEventRequestListener</i> automatically sends a delivered notification to the sender of the message
|
||||
if the sender has requested to be notified when the message is delivered. If you decide to create a new class that
|
||||
implements the <i>MessageEventRequestListener</i> interface, please remember to send the delivered notification.</p>
|
||||
<ul>
|
||||
<li>To create a new <i>MessageEventManager</i> use the <i><b>MessageEventManager(XMPPConnection)</b></i> constructor.
|
||||
<li>To create a new <i>MessageEventManager</i> use the <i><b>MessageEventManager(Connection)</b></i> constructor.
|
||||
</li>
|
||||
<li>To create an event notification requests listener create a subclass of <i><b>DefaultMessageEventRequestListener</b></i> or
|
||||
create a class that implements the <i><b>MessageEventRequestListener</b></i> interface.
|
||||
|
@ -178,9 +178,9 @@ will probably want to react to some or all of these events.</p>
|
|||
|
||||
The general idea is to create a new <i>MessageEventNotificationListener</i> that will listen to the event notifications
|
||||
and react with custom logic. Then you will have to add the listener to the <i>MessageEventManager</i> that works on
|
||||
the desired <i>XMPPConnection</i>.
|
||||
the desired <i>Connection</i>.
|
||||
<ul>
|
||||
<li>To create a new <i>MessageEventManager</i> use the <i><b>MessageEventManager(XMPPConnection)</b></i> constructor.
|
||||
<li>To create a new <i>MessageEventManager</i> use the <i><b>MessageEventManager(Connection)</b></i> constructor.
|
||||
</li>
|
||||
<li>To create an event notifications listener create a class that implements the <i><b>MessageEventNotificationListener</b></i>
|
||||
interface.
|
||||
|
|
|
@ -51,7 +51,7 @@ the form and finally send it back to the server.</p>
|
|||
|
||||
In this example we can see how to create an instant room: <br>
|
||||
<blockquote>
|
||||
<pre> <font color="#3f7f5f">// Create a MultiUserChat using an XMPPConnection for a room</font>
|
||||
<pre> <font color="#3f7f5f">// Create a MultiUserChat using a Connection for a room</font>
|
||||
MultiUserChat muc = new MultiUserChat(conn1, <font color="#0000FF">"myroom@conference.jabber.org"</font>);
|
||||
|
||||
<font color="#3f7f5f">// Create the room</font>
|
||||
|
@ -65,7 +65,7 @@ In this example we can see how to create an instant room: <br>
|
|||
|
||||
In this example we can see how to create a reserved room. The form is completed with default values: <br>
|
||||
<blockquote>
|
||||
<pre> <font color="#3f7f5f">// Create a MultiUserChat using an XMPPConnection for a room</font>
|
||||
<pre> <font color="#3f7f5f">// Create a MultiUserChat using a Connection for a room</font>
|
||||
MultiUserChat muc = new MultiUserChat(conn1, <font color="#0000FF">"myroom@conference.jabber.org"</font>);
|
||||
|
||||
<font color="#3f7f5f">// Create the room</font>
|
||||
|
@ -121,7 +121,7 @@ for a response from the server.</p>
|
|||
|
||||
In this example we can see how to join a room with a given nickname: <br>
|
||||
<blockquote>
|
||||
<pre> <font color="#3f7f5f">// Create a MultiUserChat using an XMPPConnection for a room</font>
|
||||
<pre> <font color="#3f7f5f">// Create a MultiUserChat using a Connection for a room</font>
|
||||
MultiUserChat muc2 = new MultiUserChat(conn1, <font color="#0000FF">"myroom@conference.jabber.org"</font>);
|
||||
|
||||
<font color="#3f7f5f">// User2 joins the new room</font>
|
||||
|
@ -132,7 +132,7 @@ In this example we can see how to join a room with a given nickname: <br>
|
|||
|
||||
In this example we can see how to join a room with a given nickname and password: <br>
|
||||
<blockquote>
|
||||
<pre> <font color="#3f7f5f">// Create a MultiUserChat using an XMPPConnection for a room</font>
|
||||
<pre> <font color="#3f7f5f">// Create a MultiUserChat using a Connection for a room</font>
|
||||
MultiUserChat muc2 = new MultiUserChat(conn1, <font color="#0000FF">"myroom@conference.jabber.org"</font>);
|
||||
|
||||
<font color="#3f7f5f">// User2 joins the new room using a password</font>
|
||||
|
@ -144,7 +144,7 @@ In this example we can see how to join a room with a given nickname and password
|
|||
In this example we can see how to join a room with a given nickname specifying the amount of history
|
||||
to receive: <br>
|
||||
<blockquote>
|
||||
<pre> <font color="#3f7f5f">// Create a MultiUserChat using an XMPPConnection for a room</font>
|
||||
<pre> <font color="#3f7f5f">// Create a MultiUserChat using a Connection for a room</font>
|
||||
MultiUserChat muc2 = new MultiUserChat(conn1, <font color="#0000FF">"myroom@conference.jabber.org"</font>);
|
||||
|
||||
<font color="#3f7f5f">// User2 joins the new room using a password and specifying</font>
|
||||
|
@ -205,7 +205,7 @@ In this example we can see how to listen for room invitations and decline invita
|
|||
<blockquote>
|
||||
<pre> <font color="#3f7f5f">// User3 listens for MUC invitations</font>
|
||||
MultiUserChat.addInvitationListener(conn3, new InvitationListener() {
|
||||
public void invitationReceived(XMPPConnection conn, String room, String inviter, String reason, String password) {
|
||||
public void invitationReceived(Connection conn, String room, String inviter, String reason, String password) {
|
||||
<font color="#3f7f5f">// Reject the invitation</font>
|
||||
MultiUserChat.decline(conn, room, inviter, <font color="#0000FF">"I'm busy right now"</font>);
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ A user may want to discover if one of the user's contacts supports the Multi-Use
|
|||
<b>Usage</b><p>
|
||||
|
||||
In order to discover if one of the user's contacts supports MUC just send
|
||||
<b>isServiceEnabled(XMPPConnection connection, String user)</b> to the <i><b>MultiUserChat</b></i>
|
||||
<b>isServiceEnabled(Connection connection, String user)</b> to the <i><b>MultiUserChat</b></i>
|
||||
class where user is a fully qualified XMPP ID, e.g. jdoe@example.com. You will receive
|
||||
a boolean indicating whether the user supports MUC or not.</p>
|
||||
|
||||
|
@ -248,7 +248,7 @@ A user may also want to query a contact regarding which rooms the contact is in.
|
|||
<b>Usage</b><p>
|
||||
|
||||
In order to get the rooms where a user is in just send
|
||||
<b>getJoinedRooms(XMPPConnection connection, String user)</b> to the <i><b>MultiUserChat</b></i>
|
||||
<b>getJoinedRooms(Connection connection, String user)</b> to the <i><b>MultiUserChat</b></i>
|
||||
class where user is a fully qualified XMPP ID, e.g. jdoe@example.com. You will get an Iterator
|
||||
of Strings as an answer where each String represents a room name.</p>
|
||||
|
||||
|
@ -272,7 +272,7 @@ will provide information only for public rooms.</p>
|
|||
|
||||
<b>Usage</b><p>
|
||||
|
||||
In order to discover information about a room just send <b>getRoomInfo(XMPPConnection connection, String room)</b>
|
||||
In order to discover information about a room just send <b>getRoomInfo(Connection connection, String room)</b>
|
||||
to the <i><b>MultiUserChat</b></i> class where room is the XMPP ID of the room, e.g.
|
||||
roomName@conference.myserver. You will get a RoomInfo object that contains the discovered room
|
||||
information.</p>
|
||||
|
|
|
@ -47,7 +47,7 @@ a fully configured node.</p><p>
|
|||
Create an instant node: <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
||||
<font color="#3f7f5f">// Create the node</font>
|
||||
|
@ -58,7 +58,7 @@ Create an instant node: <br>
|
|||
Create a node with default configuration and then configure it: <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
||||
<font color="#3f7f5f">// Create the node</font>
|
||||
|
@ -77,7 +77,7 @@ Create a node with default configuration and then configure it: <br>
|
|||
Create and configure a node: <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
||||
<font color="#3f7f5f">// Create the node</font>
|
||||
|
@ -117,7 +117,7 @@ will be dependent on its configuration.
|
|||
In this example we publish an item to a node that does not take payload: <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
||||
<font color="#3f7f5f">// Get the node</font>
|
||||
|
@ -133,7 +133,7 @@ In this example we publish an item to a node that does not take payload: <br>
|
|||
In this example we publish an item to a node that does take payload: <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
||||
<font color="#3f7f5f">// Get the node</font>
|
||||
|
@ -174,7 +174,7 @@ In this example we can see how to create a listener and register it and then sub
|
|||
messages. <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
||||
<font color="#3f7f5f">// Get the node</font>
|
||||
|
@ -212,7 +212,7 @@ In this example we can see how to create a listener, register it and then subscr
|
|||
item deletion messages. <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
||||
<font color="#3f7f5f">// Get the node</font>
|
||||
|
@ -250,7 +250,7 @@ In this example we can see how to create a listener, register it and then subscr
|
|||
node configuration messages. <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
||||
<font color="#3f7f5f">// Get the node</font>
|
||||
|
@ -315,7 +315,7 @@ of a <i><b>LeafNode</b></i> and call one of the retrieve methods.
|
|||
In this example we can see how to retrieve the existing items from a node: <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
||||
<font color="#3f7f5f">// Get the node</font>
|
||||
|
@ -329,7 +329,7 @@ In this example we can see how to retrieve the existing items from a node: <br>
|
|||
In this example we can see how to retrieve the last N existing items: <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
||||
<font color="#3f7f5f">// Get the node</font>
|
||||
|
@ -343,7 +343,7 @@ In this example we can see how to retrieve the specified existing items: <br>
|
|||
<blockquote>
|
||||
<pre>
|
||||
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
||||
<font color="#3f7f5f">// Get the node</font>
|
||||
|
@ -375,7 +375,7 @@ or <i><b>Node</b></i> classes depending on what type of information is required.
|
|||
In this example we can see how to get pubsub capabilities: <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
||||
<font color="#3f7f5f">// Get the pubsub features that are supported</font>
|
||||
|
@ -386,7 +386,7 @@ In this example we can see how to get pubsub capabilities: <br>
|
|||
In this example we can see how to get pubsub subscriptions for all nodes: <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
||||
<font color="#3f7f5f">// Get all the subscriptions in the pubsub service</font>
|
||||
|
@ -397,7 +397,7 @@ In this example we can see how to get pubsub subscriptions for all nodes: <br>
|
|||
In this example we can see how to get all affiliations for the users bare JID on the pubsub service: <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
||||
<font color="#3f7f5f">// Get the affiliations for the users bare JID</font>
|
||||
|
@ -408,7 +408,7 @@ In this example we can see how to get all affiliations for the users bare JID on
|
|||
In this example we can see how to get information about the node: <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
Node node = mgr.getNode(<font color="#0000FF">"testNode"</font>);
|
||||
|
||||
|
@ -420,7 +420,7 @@ In this example we can see how to get information about the node: <br>
|
|||
In this example we can see how to discover the node items: <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
Node node = mgr.getNode(<font color="#0000FF">"testNode"</font>);
|
||||
|
||||
|
@ -432,7 +432,7 @@ In this example we can see how to discover the node items: <br>
|
|||
In this example we can see how to get node subscriptions: <br>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
Node node = mgr.getNode(<font color="#0000FF">"testNode"</font>);
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ received.</p>
|
|||
<li>Create a class that implements the <i><b>RosterExchangeListener</b></i> interface.</li>
|
||||
<li>Implement the method <b>entriesReceived(String, Iterator)</b> that will be called when new entries
|
||||
are received with custom logic.</li>
|
||||
<li>Add the listener to the <i>RosterExchangeManager</i> that works on the desired <i>XMPPConnection</i>.</li>
|
||||
<li>Add the listener to the <i>RosterExchangeManager</i> that works on the desired <i>Connection</i>.</li>
|
||||
</ol></p>
|
||||
|
||||
<b>Example</b><p>
|
||||
|
|
|
@ -97,7 +97,7 @@ the message as you do with any other message.</p>
|
|||
An XHTML message is like any regular message, therefore to send the message you can follow
|
||||
the usual steps you do in order to send a message. For example, to send a message as part
|
||||
of a chat just use the message <b>#send(Message)</b> of <i><b>Chat</b></i> or you can use
|
||||
the message <b>#send(Packet)</b> of <i><b>XMPPConnection</b></i>.</p>
|
||||
the message <b>#send(Packet)</b> of <i><b>Connection</b></i>.</p>
|
||||
|
||||
<b>Example</b><p>
|
||||
|
||||
|
@ -170,7 +170,7 @@ section explains how to explicitly discover for XHTML support.</p>
|
|||
|
||||
<b>Usage</b><p>
|
||||
|
||||
In order to discover if a remote user supports XHTML messages send <b>#isServiceEnabled(XMPPConnection
|
||||
In order to discover if a remote user supports XHTML messages send <b>#isServiceEnabled(Connection
|
||||
connection, String userID)</b> to the class <i><b>XHTMLManager</b></i> where connection is the connection
|
||||
to use to perform the service discovery and userID is the user to check (A fully qualified xmpp ID,
|
||||
e.g. jdoe@example.com). This message will return true if the specified user handles XHTML messages.</p>
|
||||
|
|
|
@ -50,12 +50,12 @@ XMPP server. Below are code examples for making a connection:<p>
|
|||
<div class="code">
|
||||
<pre>
|
||||
<font color="gray"><i>// Create a connection to the jabber.org server.</i></font>
|
||||
XMPPConnection conn1 = <font color="navy"><b>new</b></font> XMPPConnection(<font color="green">"jabber.org"</font>);
|
||||
Connection conn1 = <font color="navy"><b>new</b></font> XMPPConnection(<font color="green">"jabber.org"</font>);
|
||||
conn1.connect();
|
||||
|
||||
<font color="gray"><i>// Create a connection to the jabber.org server on a specific port.</i></font>
|
||||
ConnectionConfiguration config = new ConnectionConfiguration(<font color="green">"jabber.org"</font>, 5222);
|
||||
XMPPConnection conn2 = <font color="navy"><b>new</b></font> XMPPConnection(config);
|
||||
Connection conn2 = <font color="navy"><b>new</b></font> XMPPConnection(config);
|
||||
conn2.connect();
|
||||
</pre></div>
|
||||
|
||||
|
@ -65,7 +65,7 @@ conn2.connect();
|
|||
<a href="connections.html">Connection Management</a> for full details.</p>
|
||||
|
||||
<p>Once you've created a connection, you should login using a username and password
|
||||
with the <tt>XMPPConnection.login(String username, String password)</tt> method.
|
||||
with the <tt>Connection.login(String username, String password)</tt> method.
|
||||
Once you've logged in, you can being chatting with other users by creating
|
||||
new <tt>Chat</tt> or <tt>GroupChat</tt> objects.
|
||||
|
||||
|
@ -76,7 +76,7 @@ The roster lets you keep track of the availability (presence) of other users. Us
|
|||
can be organized into groups such as "Friends" and "Co-workers", and then you
|
||||
discover whether each user is online or offline.<p>
|
||||
|
||||
Retrieve the roster using the <tt>XMPPConnection.getRoster()</tt> method. The roster
|
||||
Retrieve the roster using the <tt>Connection.getRoster()</tt> method. The roster
|
||||
class allows you to find all the roster entries, the groups they belong to, and the
|
||||
current presence status of each entry.
|
||||
|
||||
|
@ -98,7 +98,7 @@ and "out fishing":<p>
|
|||
<font color="gray"><i>// Create a new presence. Pass in false to indicate we're unavailable.</i></font>
|
||||
Presence presence = new Presence(Presence.Type.unavailable);
|
||||
presence.setStatus(<font color="green">"Gone fishing"</font>);
|
||||
<font color="gray"><i>// Send the packet (assume we have a XMPPConnection instance called "con").</i></font>
|
||||
<font color="gray"><i>// Send the packet (assume we have a Connection instance called "con").</i></font>
|
||||
con.sendPacket(presence);
|
||||
</pre></div>
|
||||
<p>
|
||||
|
@ -111,7 +111,7 @@ polling and blocking operations on. So, a packet listener is useful when
|
|||
you want to take some action whenever a packet happens to come in, while a
|
||||
packet collector is useful when you want to wait for a specific packet
|
||||
to arrive. Packet collectors and listeners can be created using an
|
||||
XMPPConnection instance.
|
||||
Connection instance.
|
||||
|
||||
|
||||
<p><div class="footer">
|
||||
|
|
|
@ -29,7 +29,7 @@ A chat creates a new thread of messages (using a thread ID) between two users. T
|
|||
following code snippet demonstrates how to create a new Chat with a user and then send
|
||||
them a text message:<p>
|
||||
|
||||
<div class="code"><pre><font color="gray"><i>// Assume we've created an XMPPConnection name "connection".</i></font>
|
||||
<div class="code"><pre><font color="gray"><i>// Assume we've created a Connection name "connection".</i></font>
|
||||
ChatManager chatmanager = connection.getChatManager();
|
||||
Chat newChat = chatmanager.createChat(<font
|
||||
color="green">"jsmith@jivesoftware.com"</font>, new MessageListener() {
|
||||
|
|
|
@ -28,7 +28,7 @@ Smack Key Advantages
|
|||
can be accomplished in only a few lines of code:
|
||||
|
||||
<div class="code"><pre>
|
||||
XMPPConnection connection = <font color="navy"><b>new</b></font> XMPPConnection(<font color="green">"jabber.org"</font>);
|
||||
Connection connection = <font color="navy"><b>new</b></font> XMPPConnection(<font color="green">"jabber.org"</font>);
|
||||
connection.connect();
|
||||
connection.login(<font color="green">"mtucker"</font>, <font color="green">"password"</font>);
|
||||
Chat chat = connection.getChatManager().createChat(<font color="green">"jsmith@jivesoftware.com"</font>, new MessageListener() {
|
||||
|
|
|
@ -27,7 +27,7 @@ A packet listener is used for event style programming, while a packet collector
|
|||
result queue of packets that you can do polling and blocking operations on. So, a packet
|
||||
listener is useful when you want to take some action whenever a packet happens to come in,
|
||||
while a packet collector is useful when you want to wait for a specific packet to
|
||||
arrive. Packet collectors and listeners can be created using an <tt>XMPPConnection</tt> instance.<p>
|
||||
arrive. Packet collectors and listeners can be created using an <tt>Connection</tt> instance.<p>
|
||||
|
||||
The <tt>org.jivesoftware.smack.filter.PacketFilter</tt> interface determines which
|
||||
specific packets will be delivered to a <tt>PacketCollector</tt> or <tt>PacketListener</tt>.
|
||||
|
@ -42,7 +42,7 @@ listener:<p>
|
|||
<font color="gray"><i>// user. We use an AndFilter to combine two other filters.</i></font>
|
||||
PacketFilter filter = new AndFilter(new PacketTypeFilter(<b>Message.class</b>),
|
||||
new FromContainsFilter(<font color="green">"mary@jivesoftware.com"</font>));
|
||||
<font color="gray"><i>// Assume we've created an XMPPConnection name "connection".</i></font>
|
||||
<font color="gray"><i>// Assume we've created a Connection name "connection".</i></font>
|
||||
|
||||
<font color="gray"><i>// First, register a packet collector using the filter we created.</i></font>
|
||||
PacketCollector myCollector = connection.createPacketCollector(filter);
|
||||
|
|
|
@ -21,7 +21,7 @@ A roster also allows you to organize users into groups such as "Friends" and
|
|||
"Co-workers". Other IM systems refer to the roster as the buddy list, contact list,
|
||||
etc.<p>
|
||||
|
||||
A <tt>Roster</tt> instance is obtained using the <tt>XMPPConnection.getRoster()</tt>
|
||||
A <tt>Roster</tt> instance is obtained using the <tt>Connection.getRoster()</tt>
|
||||
method, but only after successfully logging into a server.
|
||||
|
||||
<p class="subheader">Roster Entries</p>
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.List;
|
|||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.RosterListener;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -99,7 +99,7 @@ import org.jivesoftware.smackx.provider.JingleProvider;
|
|||
* try {
|
||||
* <p/>
|
||||
* // Connect to a XMPP Server
|
||||
* XMPPConnection x1 = new XMPPConnection("xmpp.com");
|
||||
* Connection x1 = new XMPPConnection("xmpp.com");
|
||||
* x1.connect();
|
||||
* x1.login("juliet", "juliet");
|
||||
* <p/>
|
||||
|
@ -142,7 +142,7 @@ import org.jivesoftware.smackx.provider.JingleProvider;
|
|||
* try {
|
||||
* <p/>
|
||||
* // Connect to a XMPP Server
|
||||
* XMPPConnection x0 = new XMPPConnection("xmpp.com");
|
||||
* Connection x0 = new XMPPConnection("xmpp.com");
|
||||
* x0.connect();
|
||||
* x0.login("romeo", "romeo");
|
||||
* <p/>
|
||||
|
@ -197,19 +197,19 @@ public class JingleManager implements JingleSessionListener {
|
|||
private List<CreatedJingleSessionListener> creationListeners = new ArrayList<CreatedJingleSessionListener>();
|
||||
|
||||
// The XMPP connection
|
||||
private XMPPConnection connection;
|
||||
private Connection connection;
|
||||
|
||||
// The Media Managers
|
||||
private List<JingleMediaManager> jingleMediaManagers;
|
||||
|
||||
/**
|
||||
* Default constructor with a defined XMPPConnection, Transport Resolver and a Media Manager
|
||||
* Default constructor with a defined Connection, Transport Resolver and a Media Manager
|
||||
* If a fully implemented JingleMediaSession is entered, JingleManager manage Jingle signalling and jmf
|
||||
*
|
||||
* @param connection XMPP Connection to be used
|
||||
* @param jingleMediaManager an implemeted JingleMediaManager to be used.
|
||||
*/
|
||||
public JingleManager(XMPPConnection connection, List<JingleMediaManager> jingleMediaManagers) {
|
||||
public JingleManager(Connection connection, List<JingleMediaManager> jingleMediaManagers) {
|
||||
this.connection = connection;
|
||||
this.jingleMediaManagers = jingleMediaManagers;
|
||||
|
||||
|
@ -249,7 +249,7 @@ public class JingleManager implements JingleSessionListener {
|
|||
/**
|
||||
* Setup the jingle system to let the remote clients know we support Jingle.
|
||||
* (This used to be a static part of construction. The problem is a remote client might
|
||||
* attempt a Jingle connection to us after we've created an XMPPConnection, but before we've
|
||||
* attempt a Jingle connection to us after we've created a Connection, but before we've
|
||||
* setup an instance of a JingleManager. We will appear to not support Jingle. With the new
|
||||
* method you just call it once and all new connections will report Jingle support.)
|
||||
*/
|
||||
|
@ -260,8 +260,8 @@ public class JingleManager implements JingleSessionListener {
|
|||
// Enable the Jingle support on every established connection
|
||||
// The ServiceDiscoveryManager class should have been already
|
||||
// initialized
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(Connection connection) {
|
||||
JingleManager.setServiceEnabled(connection, true);
|
||||
}
|
||||
});
|
||||
|
@ -279,7 +279,7 @@ public class JingleManager implements JingleSessionListener {
|
|||
* disabled
|
||||
* @param enabled indicates if the service will be enabled or disabled
|
||||
*/
|
||||
public synchronized static void setServiceEnabled(XMPPConnection connection, boolean enabled) {
|
||||
public synchronized static void setServiceEnabled(Connection connection, boolean enabled) {
|
||||
if (isServiceEnabled(connection) == enabled) {
|
||||
return;
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ public class JingleManager implements JingleSessionListener {
|
|||
* @return a boolean indicating if the Jingle support is enabled for the
|
||||
* given connection
|
||||
*/
|
||||
public static boolean isServiceEnabled(XMPPConnection connection) {
|
||||
public static boolean isServiceEnabled(Connection connection) {
|
||||
return ServiceDiscoveryManager.getInstanceFor(connection).includesFeature(Jingle.NAMESPACE);
|
||||
}
|
||||
|
||||
|
@ -311,7 +311,7 @@ public class JingleManager implements JingleSessionListener {
|
|||
* @return a boolean indicating whether the specified user handles Jingle
|
||||
* messages
|
||||
*/
|
||||
public static boolean isServiceEnabled(XMPPConnection connection, String userID) {
|
||||
public static boolean isServiceEnabled(Connection connection, String userID) {
|
||||
try {
|
||||
DiscoverInfo result = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(userID);
|
||||
return result.containsFeature(Jingle.NAMESPACE);
|
||||
|
|
|
@ -22,7 +22,7 @@ package org.jivesoftware.smackx.jingle;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smackx.jingle.listeners.JingleListener;
|
||||
|
@ -45,7 +45,7 @@ public abstract class JingleNegotiator {
|
|||
|
||||
private static final SmackLogger LOGGER = SmackLogger.getLogger(JingleNegotiator.class);
|
||||
|
||||
//private XMPPConnection connection; // The connection associated
|
||||
//private Connection connection; // The connection associated
|
||||
|
||||
protected JingleSession session;
|
||||
|
||||
|
@ -65,7 +65,7 @@ public abstract class JingleNegotiator {
|
|||
}
|
||||
|
||||
/**
|
||||
* Default constructor with a XMPPConnection
|
||||
* Default constructor with a Connection
|
||||
*
|
||||
* @param connection the connection associated
|
||||
*/
|
||||
|
@ -101,7 +101,7 @@ public abstract class JingleNegotiator {
|
|||
this.state = stateIs;
|
||||
}
|
||||
|
||||
public XMPPConnection getConnection() {
|
||||
public Connection getConnection() {
|
||||
if (session != null) {
|
||||
return session.getConnection();
|
||||
} else {
|
||||
|
|
|
@ -60,7 +60,7 @@ import java.util.Random;
|
|||
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -124,7 +124,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
|
||||
private JingleSessionRequest sessionRequest;
|
||||
|
||||
private XMPPConnection connection;
|
||||
private Connection connection;
|
||||
|
||||
private String sessionInitPacketID;
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
* Full featured JingleSession constructor
|
||||
*
|
||||
* @param conn
|
||||
* XMPPConnection
|
||||
* the Connection which is used
|
||||
* @param initiator
|
||||
* the initiator JID
|
||||
* @param responder
|
||||
|
@ -144,7 +144,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
* @param jingleMediaManager
|
||||
* the jingleMediaManager
|
||||
*/
|
||||
public JingleSession(XMPPConnection conn, String initiator, String responder, String sessionid,
|
||||
public JingleSession(Connection conn, String initiator, String responder, String sessionid,
|
||||
List<JingleMediaManager> jingleMediaManagers) {
|
||||
super();
|
||||
|
||||
|
@ -170,7 +170,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
* JingleSession constructor (for an outgoing Jingle session)
|
||||
*
|
||||
* @param conn
|
||||
* XMPPConnection
|
||||
* Connection
|
||||
* @param initiator
|
||||
* the initiator JID
|
||||
* @param responder
|
||||
|
@ -178,7 +178,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
* @param jingleMediaManager
|
||||
* the jingleMediaManager
|
||||
*/
|
||||
public JingleSession(XMPPConnection conn, JingleSessionRequest request, String initiator, String responder,
|
||||
public JingleSession(Connection conn, JingleSessionRequest request, String initiator, String responder,
|
||||
List<JingleMediaManager> jingleMediaManagers) {
|
||||
this(conn, initiator, responder, generateSessionId(), jingleMediaManagers);
|
||||
sessionRequest = request;
|
||||
|
@ -193,7 +193,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
return initiator;
|
||||
}
|
||||
|
||||
public XMPPConnection getConnection() {
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
@ -640,7 +640,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
* @param connection
|
||||
* The connection to clean up
|
||||
*/
|
||||
private void unregisterInstanceFor(XMPPConnection connection) {
|
||||
private void unregisterInstanceFor(Connection connection) {
|
||||
synchronized (sessions) {
|
||||
sessions.remove(connection);
|
||||
}
|
||||
|
@ -662,7 +662,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
* A XMPP connection
|
||||
* @return a Jingle session
|
||||
*/
|
||||
public static JingleSession getInstanceFor(XMPPConnection con) {
|
||||
public static JingleSession getInstanceFor(Connection con) {
|
||||
if (con == null) {
|
||||
throw new IllegalArgumentException("Connection cannot be null");
|
||||
}
|
||||
|
@ -683,7 +683,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
* @param connection
|
||||
* The connection to set up
|
||||
*/
|
||||
private void installConnectionListeners(final XMPPConnection connection) {
|
||||
private void installConnectionListeners(final Connection connection) {
|
||||
if (connection != null) {
|
||||
connectionListener = new ConnectionListener() {
|
||||
public void connectionClosed() {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle.mediaimpl.demo;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||
|
@ -43,7 +44,7 @@ import java.util.List;
|
|||
public class Demo extends JFrame {
|
||||
|
||||
private JingleTransportManager transportManager = null;
|
||||
private XMPPConnection xmppConnection = null;
|
||||
private Connection xmppConnection = null;
|
||||
|
||||
private String server = null;
|
||||
private String user = null;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle.nat;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||
|
||||
|
@ -40,7 +40,7 @@ import java.util.Random;
|
|||
*/
|
||||
public class BridgedResolver extends TransportResolver {
|
||||
|
||||
XMPPConnection connection;
|
||||
Connection connection;
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
|
@ -48,9 +48,9 @@ public class BridgedResolver extends TransportResolver {
|
|||
|
||||
/**
|
||||
* Constructor.
|
||||
* A Bridged Resolver need a XMPPConnection to connect to a RTP Bridge.
|
||||
* A Bridged Resolver need a Connection to connect to a RTP Bridge.
|
||||
*/
|
||||
public BridgedResolver(XMPPConnection connection) {
|
||||
public BridgedResolver(Connection connection) {
|
||||
super();
|
||||
this.connection = connection;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle.nat;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||
import org.jivesoftware.smackx.jingle.listeners.CreatedJingleSessionListener;
|
||||
|
@ -35,9 +35,9 @@ import org.jivesoftware.smackx.jingle.media.PayloadType;
|
|||
*/
|
||||
public class BridgedTransportManager extends JingleTransportManager implements JingleSessionListener, CreatedJingleSessionListener {
|
||||
|
||||
XMPPConnection xmppConnection;
|
||||
Connection xmppConnection;
|
||||
|
||||
public BridgedTransportManager(XMPPConnection xmppConnection) {
|
||||
public BridgedTransportManager(Connection xmppConnection) {
|
||||
super();
|
||||
this.xmppConnection = xmppConnection;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||
import org.jivesoftware.smackx.jingle.SmackLogger;
|
||||
|
@ -49,7 +49,7 @@ public class ICEResolver extends TransportResolver {
|
|||
|
||||
private static final SmackLogger LOGGER = SmackLogger.getLogger(ICEResolver.class);
|
||||
|
||||
XMPPConnection connection;
|
||||
Connection connection;
|
||||
Random random = new Random();
|
||||
long sid;
|
||||
String server;
|
||||
|
@ -57,7 +57,7 @@ public class ICEResolver extends TransportResolver {
|
|||
static Map<String, ICENegociator> negociatorsMap = new HashMap<String, ICENegociator>();
|
||||
//ICENegociator iceNegociator = null;
|
||||
|
||||
public ICEResolver(XMPPConnection connection, String server, int port) {
|
||||
public ICEResolver(Connection connection, String server, int port) {
|
||||
super();
|
||||
this.connection = connection;
|
||||
this.server = server;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.jivesoftware.smackx.jingle.nat;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||
import org.jivesoftware.smackx.jingle.listeners.CreatedJingleSessionListener;
|
||||
|
@ -30,7 +30,7 @@ public class ICETransportManager extends JingleTransportManager implements Jingl
|
|||
|
||||
ICEResolver iceResolver = null;
|
||||
|
||||
public ICETransportManager(XMPPConnection xmppConnection, String server, int port) {
|
||||
public ICETransportManager(Connection xmppConnection, String server, int port) {
|
||||
iceResolver = new ICEResolver(xmppConnection, server, port);
|
||||
try {
|
||||
iceResolver.initializeAndWait();
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.Iterator;
|
|||
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -46,7 +46,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
* <p/>
|
||||
* High Level Usage Example:
|
||||
* <p/>
|
||||
* RTPBridge rtpBridge = RTPBridge.getRTPBridge(xmppConnection, sessionID);
|
||||
* RTPBridge rtpBridge = RTPBridge.getRTPBridge(connection, sessionID);
|
||||
*
|
||||
* @author Thiago Camargo
|
||||
*/
|
||||
|
@ -388,23 +388,23 @@ public class RTPBridge extends IQ {
|
|||
* Get a new RTPBridge Candidate from the server.
|
||||
* If a error occurs or the server don't support RTPBridge Service, null is returned.
|
||||
*
|
||||
* @param xmppConnection
|
||||
* @param connection
|
||||
* @param sessionID
|
||||
* @return
|
||||
*/
|
||||
public static RTPBridge getRTPBridge(XMPPConnection xmppConnection, String sessionID) {
|
||||
public static RTPBridge getRTPBridge(Connection connection, String sessionID) {
|
||||
|
||||
if (!xmppConnection.isConnected()) {
|
||||
if (!connection.isConnected()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
RTPBridge rtpPacket = new RTPBridge(sessionID);
|
||||
rtpPacket.setTo(RTPBridge.NAME + "." + xmppConnection.getServiceName());
|
||||
rtpPacket.setTo(RTPBridge.NAME + "." + connection.getServiceName());
|
||||
|
||||
PacketCollector collector = xmppConnection
|
||||
PacketCollector collector = connection
|
||||
.createPacketCollector(new PacketIDFilter(rtpPacket.getPacketID()));
|
||||
|
||||
xmppConnection.sendPacket(rtpPacket);
|
||||
connection.sendPacket(rtpPacket);
|
||||
|
||||
RTPBridge response = (RTPBridge) collector
|
||||
.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||
|
@ -418,21 +418,21 @@ public class RTPBridge extends IQ {
|
|||
/**
|
||||
* Check if the server support RTPBridge Service.
|
||||
*
|
||||
* @param xmppConnection
|
||||
* @param connection
|
||||
* @return
|
||||
*/
|
||||
public static boolean serviceAvailable(XMPPConnection xmppConnection) {
|
||||
public static boolean serviceAvailable(Connection connection) {
|
||||
|
||||
if (!xmppConnection.isConnected()) {
|
||||
if (!connection.isConnected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGGER.debug("Service listing");
|
||||
|
||||
ServiceDiscoveryManager disco = ServiceDiscoveryManager
|
||||
.getInstanceFor(xmppConnection);
|
||||
.getInstanceFor(connection);
|
||||
try {
|
||||
// DiscoverItems items = disco.discoverItems(xmppConnection.getServiceName());
|
||||
// DiscoverItems items = disco.discoverItems(connection.getServiceName());
|
||||
// Iterator iter = items.getItems();
|
||||
// while (iter.hasNext()) {
|
||||
// DiscoverItems.Item item = (DiscoverItems.Item) iter.next();
|
||||
|
@ -441,7 +441,7 @@ public class RTPBridge extends IQ {
|
|||
// }
|
||||
// }
|
||||
|
||||
DiscoverInfo discoInfo = disco.discoverInfo(xmppConnection.getServiceName());
|
||||
DiscoverInfo discoInfo = disco.discoverInfo(connection.getServiceName());
|
||||
Iterator iter = discoInfo.getIdentities();
|
||||
while (iter.hasNext()) {
|
||||
DiscoverInfo.Identity identity = (DiscoverInfo.Identity) iter.next();
|
||||
|
@ -460,17 +460,17 @@ public class RTPBridge extends IQ {
|
|||
/**
|
||||
* Check if the server support RTPBridge Service.
|
||||
*
|
||||
* @param xmppConnection
|
||||
* @param connection
|
||||
* @return
|
||||
*/
|
||||
public static RTPBridge relaySession(XMPPConnection xmppConnection, String sessionID, String pass, TransportCandidate proxyCandidate, TransportCandidate localCandidate) {
|
||||
public static RTPBridge relaySession(Connection connection, String sessionID, String pass, TransportCandidate proxyCandidate, TransportCandidate localCandidate) {
|
||||
|
||||
if (!xmppConnection.isConnected()) {
|
||||
if (!connection.isConnected()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
RTPBridge rtpPacket = new RTPBridge(sessionID, RTPBridge.BridgeAction.change);
|
||||
rtpPacket.setTo(RTPBridge.NAME + "." + xmppConnection.getServiceName());
|
||||
rtpPacket.setTo(RTPBridge.NAME + "." + connection.getServiceName());
|
||||
rtpPacket.setType(Type.SET);
|
||||
|
||||
rtpPacket.setPass(pass);
|
||||
|
@ -481,10 +481,10 @@ public class RTPBridge extends IQ {
|
|||
|
||||
// LOGGER.debug("Relayed to: " + candidate.getIp() + ":" + candidate.getPort());
|
||||
|
||||
PacketCollector collector = xmppConnection
|
||||
PacketCollector collector = connection
|
||||
.createPacketCollector(new PacketIDFilter(rtpPacket.getPacketID()));
|
||||
|
||||
xmppConnection.sendPacket(rtpPacket);
|
||||
connection.sendPacket(rtpPacket);
|
||||
|
||||
RTPBridge response = (RTPBridge) collector
|
||||
.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||
|
@ -501,7 +501,7 @@ public class RTPBridge extends IQ {
|
|||
* @param xmppConnection
|
||||
* @return public IP String or null if not found
|
||||
*/
|
||||
public static String getPublicIP(XMPPConnection xmppConnection) {
|
||||
public static String getPublicIP(Connection xmppConnection) {
|
||||
|
||||
if (!xmppConnection.isConnected()) {
|
||||
return null;
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -42,7 +42,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
* <p/>
|
||||
* High Level Usage Example:
|
||||
* <p/>
|
||||
* STUN stun = STUN.getSTUNServer(xmppConnection);
|
||||
* STUN stun = STUN.getSTUNServer(connection);
|
||||
*
|
||||
* @author Thiago Camargo
|
||||
*/
|
||||
|
@ -185,22 +185,22 @@ public class STUN extends IQ {
|
|||
* Get a new STUN Server Address and port from the server.
|
||||
* If a error occurs or the server don't support STUN Service, null is returned.
|
||||
*
|
||||
* @param xmppConnection
|
||||
* @param connection
|
||||
* @return
|
||||
*/
|
||||
public static STUN getSTUNServer(XMPPConnection xmppConnection) {
|
||||
public static STUN getSTUNServer(Connection connection) {
|
||||
|
||||
if (!xmppConnection.isConnected()) {
|
||||
if (!connection.isConnected()) {
|
||||