public class XMPPTCPConnection extends XMPPConnection
XMPPConnectionXMPPConnection.FromMode, XMPPConnection.InterceptorWrapper, XMPPConnection.ListenerWrapperauthenticated, collectors, compressionHandler, config, connectionCounterValue, connectionListeners, debugger, interceptors, reader, recvListeners, saslAuthentication, sendListeners, wasAuthenticated, writer| Constructor and Description |
|---|
XMPPTCPConnection(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(ConnectionConfiguration config,
CallbackHandler callbackHandler)
Creates a new XMPP connection using the specified connection configuration.
|
XMPPTCPConnection(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(String serviceName,
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).
|
protected ConnectionConfiguration |
getConfiguration()
Returns the configuration used to connect to the server.
|
String |
getConnectionID()
Returns the connection ID for this connection, which is the value set by the server
when opening a XMPP stream.
|
ParsingExceptionCallback |
getParsingExceptionCallback()
Get the current active parsing exception callback.
|
protected Reader |
getReader() |
protected SASLAuthentication |
getSASLAuthentication()
Returns the SASLAuthentication manager that is responsible for authenticating with
the server.
|
String |
getUser()
Returns the full XMPP address of the user that is logged in to the connection or
null if not logged in yet.
|
protected Writer |
getWriter() |
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 |
isSocketClosed() |
boolean |
isUsingCompression()
Returns true if network traffic is being compressed.
|
boolean |
isUsingTLS()
Returns true if the connection to the server has successfully negotiated TLS.
|
void |
login(String username,
String password,
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.
|
protected void |
processPacket(Packet packet)
Processes a packet after it's been fully parsed by looping through the installed
packet collectors and listeners and letting them examine the packet to see if
they are a match with the filter.
|
protected void |
sendPacketInternal(Packet packet) |
protected void |
serverRequiresBinding()
Notification message saying that the server requires the client to bind a
resource to the stream.
|
protected void |
serverSupportsAccountCreation() |
protected void |
serverSupportsSession()
Notification message saying that the server supports sessions.
|
void |
setParsingExceptionCallback(ParsingExceptionCallback callback)
Install a parsing exception callback, which will be invoked once an exception is encountered while parsing a
stanza
|
protected void |
setRosterVersioningSupported()
Indicates that the server supports roster versioning as defined in XEP-0237.
|
protected void |
setServiceCapsNode(String node)
Set the servers Entity Caps node
XMPPConnection holds this information in order to avoid a dependency to
smackx where EntityCapsManager lives from smack.
|
protected void |
setServiceName(String serviceName) |
protected void |
shutdown()
Shuts the current connection down.
|
protected void |
throwConnectionExceptionOrNoResponse() |
addConnectionCreationListener, addConnectionListener, addPacketInterceptor, addPacketListener, addPacketSendingListener, bindResourceAndEstablishSession, callConnectionAuthenticatedListener, callConnectionClosedOnErrorListener, callConnectionConnectedListener, connect, createPacketCollector, createPacketCollectorAndSend, disconnect, disconnect, finalize, getConnectionCounter, getConnectionCreationListeners, getConnectionListeners, getFromMode, getHost, getPacketCollectors, getPacketInterceptors, getPacketListeners, getPacketReplyTimeout, getPacketSendingListeners, getPort, getRoster, getServiceCapsNode, getServiceName, initDebugger, isRosterVersioningSupported, login, maybeResolveDns, removeConnectionCreationListener, removeConnectionListener, removePacketCollector, removePacketInterceptor, removePacketListener, removePacketSendingListener, schedule, sendPacket, setConnectionException, setFromMode, setLoginInfo, setPacketReplyTimeout, setWasAuthenticatedpublic XMPPTCPConnection(String serviceName, 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
XMPPConnection.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(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(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(ConnectionConfiguration config, 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
XMPPConnection.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 String getConnectionID()
XMPPConnectiongetConnectionID in class XMPPConnectionpublic String getUser()
XMPPConnectiongetUser in class XMPPConnectionpublic void setParsingExceptionCallback(ParsingExceptionCallback callback)
callback - the callback to installpublic ParsingExceptionCallback getParsingExceptionCallback()
public void login(String username, String password, String resource) throws XMPPException, SmackException, SaslException, IOException
XMPPConnection
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 XMPPConnectionusername - the username.password - the password or null if using a CallbackHandler.resource - the resource.XMPPException - if an error occurs on the XMPP protocol level.SmackException - if an error occurs somehwere else besides XMPP protocol level.SaslExceptionIOExceptionpublic void loginAnonymously() throws XMPPException, SmackException, SaslException, IOException
XMPPConnectionloginAnonymously in class XMPPConnectionXMPPException - if an error occurs on the XMPP protocol level.SmackException - if an error occurs somehwere else besides XMPP protocol level.SaslExceptionIOExceptionpublic boolean isConnected()
XMPPConnectionisConnected in class XMPPConnectionpublic boolean isSecureConnection()
XMPPConnectionisSecureConnection in class XMPPConnectionpublic boolean isSocketClosed()
public boolean isAuthenticated()
XMPPConnectionisAuthenticated in class XMPPConnectionpublic boolean isAnonymous()
XMPPConnectionisAnonymous in class XMPPConnectionprotected void shutdown()
shutdown in class XMPPConnectionprotected void sendPacketInternal(Packet packet) throws SmackException.NotConnectedException
sendPacketInternal in class XMPPConnectionSmackException.NotConnectedExceptionpublic boolean isUsingTLS()
public boolean isUsingCompression()
XMPPConnectionisUsingCompression in class XMPPConnectionprotected void connectInternal() throws SmackException, IOException, XMPPException
Listeners will be preserved from a previous connection if the reconnection occurs after an abrupt termination.
connectInternal in class XMPPConnectionXMPPException - if an error occurs while trying to establish the connection.SmackExceptionIOExceptionprotected void processPacket(Packet packet)
XMPPConnectionprocessPacket in class XMPPConnectionpacket - the packet to process.protected Reader getReader()
getReader in class XMPPConnectionprotected Writer getWriter()
getWriter in class XMPPConnectionprotected void throwConnectionExceptionOrNoResponse() throws IOException, SmackException.NoResponseException
throwConnectionExceptionOrNoResponse in class XMPPConnectionIOExceptionSmackException.NoResponseExceptionprotected void setServiceName(String serviceName)
setServiceName in class XMPPConnectionprotected void serverRequiresBinding()
XMPPConnectionserverRequiresBinding in class XMPPConnectionprotected void setServiceCapsNode(String node)
XMPPConnectionsetServiceCapsNode in class XMPPConnectionprotected void serverSupportsSession()
XMPPConnectionserverSupportsSession in class XMPPConnectionprotected void setRosterVersioningSupported()
XMPPConnectionsetRosterVersioningSupported in class XMPPConnectionprotected void serverSupportsAccountCreation()
serverSupportsAccountCreation in class XMPPConnectionprotected SASLAuthentication getSASLAuthentication()
XMPPConnectiongetSASLAuthentication in class XMPPConnectionprotected ConnectionConfiguration getConfiguration()
XMPPConnectiongetConfiguration in class XMPPConnection