public class XMPPTCPConnection
extends org.jivesoftware.smack.AbstractXMPPConnection
XMPPConnection
Modifier and Type | Class and Description |
---|---|
protected class |
XMPPTCPConnection.PacketReader |
protected class |
XMPPTCPConnection.PacketWriter |
Constructor and Description |
---|
XMPPTCPConnection(org.jivesoftware.smack.ConnectionConfiguration config)
Creates a new XMPP connection in the same way
XMPPTCPConnection(ConnectionConfiguration,CallbackHandler) does, but
with no callback handler for password prompting of the keystore. |
XMPPTCPConnection(org.jivesoftware.smack.ConnectionConfiguration config,
javax.security.auth.callback.CallbackHandler callbackHandler)
Creates a new XMPP connection using the specified connection configuration.
|
XMPPTCPConnection(java.lang.String serviceName)
Creates a new XMPP connection in the same way
XMPPTCPConnection(String,CallbackHandler) does, but
with no callback handler for password prompting of the keystore. |
XMPPTCPConnection(java.lang.String serviceName,
javax.security.auth.callback.CallbackHandler callbackHandler)
Creates a new connection to the specified XMPP server.
|
Modifier and Type | Method and Description |
---|---|
protected void |
connectInternal()
Establishes a connection to the XMPP server and performs an automatic login
only if the previous connection state was logged (authenticated).
|
java.lang.String |
getConnectionID() |
org.jivesoftware.smack.parsing.ParsingExceptionCallback |
getParsingExceptionCallback()
Get the current active parsing exception callback.
|
java.lang.String |
getUser() |
boolean |
isAnonymous() |
boolean |
isAuthenticated() |
boolean |
isConnected() |
boolean |
isSecureConnection() |
boolean |
isSocketClosed() |
boolean |
isUsingCompression() |
void |
login(java.lang.String username,
java.lang.String password,
java.lang.String resource) |
void |
loginAnonymously() |
protected void |
sendPacketInternal(org.jivesoftware.smack.packet.Packet packet) |
void |
setParsingExceptionCallback(org.jivesoftware.smack.parsing.ParsingExceptionCallback callback)
Install a parsing exception callback, which will be invoked once an exception is encountered while parsing a
stanza
|
protected void |
shutdown()
Shuts the current connection down.
|
addConnectionListener, addPacketInterceptor, addPacketListener, addPacketSendingListener, bindResourceAndEstablishSession, callConnectionAuthenticatedListener, callConnectionClosedOnErrorListener, callConnectionConnectedListener, connect, createPacketCollector, createPacketCollectorAndSend, disconnect, disconnect, finalize, getConfiguration, getConnectionCounter, getConnectionCreationListeners, getConnectionListeners, getFromMode, getHost, getPacketCollectors, getPacketInterceptors, getPacketListeners, getPacketReplyTimeout, getPacketSendingListeners, getPort, getReader, getRoster, getRosterStore, getSASLAuthentication, getServiceCapsNode, getServiceName, getWriter, initDebugger, isRosterLoadedAtLogin, isRosterVersioningSupported, login, maybeResolveDns, processPacket, removeConnectionListener, removePacketCollector, removePacketInterceptor, removePacketListener, removePacketSendingListener, sendPacket, serverRequiresBinding, serverSupportsAccountCreation, serverSupportsSession, setConnectionException, setFromMode, setLoginInfo, setPacketReplyTimeout, setRosterVersioningSupported, setServiceCapsNode, setServiceName, setWasAuthenticated, throwConnectionExceptionOrNoResponse
public XMPPTCPConnection(java.lang.String serviceName, javax.security.auth.callback.CallbackHandler callbackHandler)
This is the simplest constructor for connecting to an XMPP server. Alternatively, you can get fine-grained control over connection settings using the
XMPPTCPConnection(ConnectionConfiguration)
constructor.Note that XMPPTCPConnection constructors do not establish a connection to the server and you must call
AbstractXMPPConnection.connect()
.The CallbackHandler will only be used if the connection requires the client provide an SSL certificate to the server. The CallbackHandler must handle the PasswordCallback to prompt for a password to unlock the keystore containing the SSL certificate.
serviceName
- the name of the XMPP server to connect to; e.g. example.com.callbackHandler
- the CallbackHandler used to prompt for the password to the keystore.public XMPPTCPConnection(java.lang.String serviceName)
XMPPTCPConnection(String,CallbackHandler)
does, but
with no callback handler for password prompting of the keystore. This will work
in most cases, provided the client is not required to provide a certificate to
the server.serviceName
- the name of the XMPP server to connect to; e.g. example.com.public XMPPTCPConnection(org.jivesoftware.smack.ConnectionConfiguration config)
XMPPTCPConnection(ConnectionConfiguration,CallbackHandler)
does, but
with no callback handler for password prompting of the keystore. This will work
in most cases, provided the client is not required to provide a certificate to
the server.config
- the connection configuration.public XMPPTCPConnection(org.jivesoftware.smack.ConnectionConfiguration config, javax.security.auth.callback.CallbackHandler callbackHandler)
Manually specifying connection configuration information is suitable for advanced users of the API. In many cases, using the
XMPPTCPConnection(String)
constructor is a better approach.Note that XMPPTCPConnection constructors do not establish a connection to the server and you must call
AbstractXMPPConnection.connect()
.The CallbackHandler will only be used if the connection requires the client provide an SSL certificate to the server. The CallbackHandler must handle the PasswordCallback to prompt for a password to unlock the keystore containing the SSL certificate.
config
- the connection configuration.callbackHandler
- the CallbackHandler used to prompt for the password to the keystore.public java.lang.String getConnectionID()
getConnectionID
in interface org.jivesoftware.smack.XMPPConnection
getConnectionID
in class org.jivesoftware.smack.AbstractXMPPConnection
public java.lang.String getUser()
getUser
in interface org.jivesoftware.smack.XMPPConnection
getUser
in class org.jivesoftware.smack.AbstractXMPPConnection
public void setParsingExceptionCallback(org.jivesoftware.smack.parsing.ParsingExceptionCallback callback)
callback
- the callback to installpublic org.jivesoftware.smack.parsing.ParsingExceptionCallback getParsingExceptionCallback()
public void login(java.lang.String username, java.lang.String password, java.lang.String resource) throws org.jivesoftware.smack.XMPPException, org.jivesoftware.smack.SmackException, javax.security.sasl.SaslException, java.io.IOException
login
in class org.jivesoftware.smack.AbstractXMPPConnection
org.jivesoftware.smack.XMPPException
org.jivesoftware.smack.SmackException
javax.security.sasl.SaslException
java.io.IOException
public void loginAnonymously() throws org.jivesoftware.smack.XMPPException, org.jivesoftware.smack.SmackException, javax.security.sasl.SaslException, java.io.IOException
loginAnonymously
in class org.jivesoftware.smack.AbstractXMPPConnection
org.jivesoftware.smack.XMPPException
org.jivesoftware.smack.SmackException
javax.security.sasl.SaslException
java.io.IOException
public boolean isConnected()
isConnected
in interface org.jivesoftware.smack.XMPPConnection
isConnected
in class org.jivesoftware.smack.AbstractXMPPConnection
public boolean isSecureConnection()
isSecureConnection
in interface org.jivesoftware.smack.XMPPConnection
isSecureConnection
in class org.jivesoftware.smack.AbstractXMPPConnection
public boolean isSocketClosed()
public boolean isAuthenticated()
isAuthenticated
in interface org.jivesoftware.smack.XMPPConnection
isAuthenticated
in class org.jivesoftware.smack.AbstractXMPPConnection
public boolean isAnonymous()
isAnonymous
in interface org.jivesoftware.smack.XMPPConnection
isAnonymous
in class org.jivesoftware.smack.AbstractXMPPConnection
protected void shutdown()
shutdown
in class org.jivesoftware.smack.AbstractXMPPConnection
protected void sendPacketInternal(org.jivesoftware.smack.packet.Packet packet) throws org.jivesoftware.smack.SmackException.NotConnectedException
sendPacketInternal
in class org.jivesoftware.smack.AbstractXMPPConnection
org.jivesoftware.smack.SmackException.NotConnectedException
public boolean isUsingCompression()
isUsingCompression
in interface org.jivesoftware.smack.XMPPConnection
isUsingCompression
in class org.jivesoftware.smack.AbstractXMPPConnection
protected void connectInternal() throws org.jivesoftware.smack.SmackException, java.io.IOException, org.jivesoftware.smack.XMPPException
Listeners will be preserved from a previous connection if the reconnection occurs after an abrupt termination.
connectInternal
in class org.jivesoftware.smack.AbstractXMPPConnection
org.jivesoftware.smack.XMPPException
- if an error occurs while trying to establish the connection.org.jivesoftware.smack.SmackException
java.io.IOException