|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jivesoftware.smack.Connection
org.jivesoftware.smack.DummyConnection
public class DummyConnection
A dummy implementation of Connection, intended to be used during
unit tests.
Instances store any packets that are delivered to be send using the
sendPacket(Packet) method in a blocking queue. The content of this queue
can be inspected using getSentPacket(). Typically these queues are
used to retrieve a message that was generated by the client.
Packets that should be processed by the client to simulate a received stanza
can be delivered using the processPacket(Packet) method.
It invokes the registered packet interceptors and listeners.
Connection| Field Summary |
|---|
| Fields inherited from class org.jivesoftware.smack.Connection |
|---|
DEBUG_ENABLED |
| Constructor Summary | |
|---|---|
DummyConnection()
|
|
DummyConnection(ConnectionConfiguration configuration)
|
|
| Method Summary | |
|---|---|
void |
connect()
Establishes a connection to the XMPP server and performs an automatic login only if the previous connection state was logged (authenticated). |
void |
disconnect(Presence unavailablePresence)
Closes the connection. |
java.lang.String |
getConnectionID()
Returns the connection ID for this connection, which is the value set by the server when opening a XMPP stream. |
int |
getNumberOfSentPackets()
Returns the number of packets that's sent through sendPacket(Packet) and
that has not been returned by getSentPacket(). |
Roster |
getRoster()
Returns the roster for the user. |
Packet |
getSentPacket()
Returns the first packet that's sent through sendPacket(Packet) and
that has not been returned by earlier calls to this method. |
java.lang.String |
getUser()
Returns the full XMPP address of the user that is logged in to the connection or null if not logged in yet. |
boolean |
isAnonymous()
Returns true if currently authenticated anonymously. |
boolean |
isAuthenticated()
Returns true if currently authenticated by successfully calling the login method. |
boolean |
isConnected()
Returns true if currently connected to the XMPP server. |
boolean |
isSecureConnection()
Returns true if the connection to the server has successfully negotiated encryption. |
boolean |
isUsingCompression()
Returns true if network traffic is being compressed. |
void |
login(java.lang.String username,
java.lang.String password,
java.lang.String resource)
Logs in to the server using the strongest authentication mode supported by the server, then sets presence to available. |
void |
loginAnonymously()
Logs in to the server anonymously. |
void |
processPacket(Packet packet)
Processes a packet through the installed packet collectors and listeners and letting them examine the packet to see if they are a match with the filter. |
void |
sendPacket(Packet packet)
Sends the specified packet to the server. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DummyConnection()
public DummyConnection(ConnectionConfiguration configuration)
| Method Detail |
|---|
public void connect()
throws XMPPException
ConnectionListeners will be preserved from a previous connection if the reconnection occurs after an abrupt termination.
connect in class ConnectionXMPPException - if an error occurs while trying to establish the connection.public void disconnect(Presence unavailablePresence)
ConnectionThis method cleans up all resources used by the connection. Therefore, the roster, listeners and other stateful objects cannot be re-used by simply calling connect() on this connection again. This is unlike the behavior during unexpected disconnects (and subsequent connections). In that case, all state is preserved to allow for more seamless error recovery.
disconnect in class ConnectionunavailablePresence - the presence packet to send during shutdown.public java.lang.String getConnectionID()
Connection
getConnectionID in class Connectionpublic Roster getRoster()
Connection
This method will never return null, instead if the user has not yet logged into
the server or is logged in anonymously all modifying methods of the returned roster object
like Roster.createEntry(String, String, String[]),
Roster.removeEntry(RosterEntry) , etc. except adding or removing
RosterListeners will throw an IllegalStateException.
getRoster in class Connectionpublic java.lang.String getUser()
Connection
getUser in class Connectionpublic boolean isAnonymous()
Connection
isAnonymous in class Connectionpublic boolean isAuthenticated()
Connection
isAuthenticated in class Connectionpublic boolean isConnected()
Connection
isConnected in class Connectionpublic boolean isSecureConnection()
Connection
isSecureConnection in class Connectionpublic boolean isUsingCompression()
Connection
isUsingCompression in class Connection
public void login(java.lang.String username,
java.lang.String password,
java.lang.String resource)
throws XMPPException
Connection
Before logging in (i.e. authenticate) to the server the connection must be connected.
It is possible to log in without sending an initial available presence by using
ConnectionConfiguration.setSendPresence(boolean). If this connection is
not interested in loading its roster upon login then use
ConnectionConfiguration.setRosterLoadedAtLogin(boolean).
Finally, if you want to not pass a password and instead use a more advanced mechanism
while using SASL then you may be interested in using
ConnectionConfiguration.setCallbackHandler(javax.security.auth.callback.CallbackHandler).
For more advanced login settings see ConnectionConfiguration.
login in class Connectionusername - the username.password - the password or null if using a CallbackHandler.resource - the resource.
XMPPException - if an error occurs.
public void loginAnonymously()
throws XMPPException
Connection
loginAnonymously in class ConnectionXMPPException - if an error occurs or anonymous logins are not supported by the server.public void sendPacket(Packet packet)
Connection
sendPacket in class Connectionpacket - the packet to send.public int getNumberOfSentPackets()
sendPacket(Packet) and
that has not been returned by getSentPacket().
public Packet getSentPacket()
throws java.lang.InterruptedException
sendPacket(Packet) and
that has not been returned by earlier calls to this method. This method
will block for up to two seconds if no packets have been sent yet.
java.lang.InterruptedExceptionpublic void processPacket(Packet packet)
packet - the packet to process.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||