public class XMPPTCPConnection
extends org.jivesoftware.smack.XMPPConnection
XMPPConnection
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).
|
protected org.jivesoftware.smack.ConnectionConfiguration |
getConfiguration() |
java.lang.String |
getConnectionID() |
org.jivesoftware.smack.parsing.ParsingExceptionCallback |
getParsingExceptionCallback()
Get the current active parsing exception callback.
|
protected java.io.Reader |
getReader() |
protected org.jivesoftware.smack.SASLAuthentication |
getSASLAuthentication() |
java.lang.String |
getUser() |
protected java.io.Writer |
getWriter() |
boolean |
isAnonymous() |
boolean |
isAuthenticated() |
boolean |
isConnected() |
boolean |
isSecureConnection() |
boolean |
isSocketClosed() |
boolean |
isUsingCompression() |
boolean |
isUsingTLS()
Returns true if the connection to the server has successfully negotiated TLS.
|
void |
login(java.lang.String username,
java.lang.String password,
java.lang.String resource) |
void |
loginAnonymously() |
protected void |
processPacket(org.jivesoftware.smack.packet.Packet packet) |
protected void |
sendPacketInternal(org.jivesoftware.smack.packet.Packet packet) |
protected void |
serverRequiresBinding() |
protected void |
serverSupportsAccountCreation() |
protected void |
serverSupportsSession() |
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 |
setRosterVersioningSupported() |
protected void |
setServiceCapsNode(java.lang.String node) |
protected void |
setServiceName(java.lang.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, setWasAuthenticated
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
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(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
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 java.lang.String getConnectionID()
getConnectionID
in class org.jivesoftware.smack.XMPPConnection
public java.lang.String getUser()
getUser
in class org.jivesoftware.smack.XMPPConnection
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.XMPPConnection
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.XMPPConnection
org.jivesoftware.smack.XMPPException
org.jivesoftware.smack.SmackException
javax.security.sasl.SaslException
java.io.IOException
public boolean isConnected()
isConnected
in class org.jivesoftware.smack.XMPPConnection
public boolean isSecureConnection()
isSecureConnection
in class org.jivesoftware.smack.XMPPConnection
public boolean isSocketClosed()
public boolean isAuthenticated()
isAuthenticated
in class org.jivesoftware.smack.XMPPConnection
public boolean isAnonymous()
isAnonymous
in class org.jivesoftware.smack.XMPPConnection
protected void shutdown()
shutdown
in class org.jivesoftware.smack.XMPPConnection
protected void sendPacketInternal(org.jivesoftware.smack.packet.Packet packet) throws org.jivesoftware.smack.SmackException.NotConnectedException
sendPacketInternal
in class org.jivesoftware.smack.XMPPConnection
org.jivesoftware.smack.SmackException.NotConnectedException
public boolean isUsingTLS()
public boolean isUsingCompression()
isUsingCompression
in class org.jivesoftware.smack.XMPPConnection
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.XMPPConnection
org.jivesoftware.smack.XMPPException
- if an error occurs while trying to establish the connection.org.jivesoftware.smack.SmackException
java.io.IOException
protected void processPacket(org.jivesoftware.smack.packet.Packet packet)
processPacket
in class org.jivesoftware.smack.XMPPConnection
protected java.io.Reader getReader()
getReader
in class org.jivesoftware.smack.XMPPConnection
protected java.io.Writer getWriter()
getWriter
in class org.jivesoftware.smack.XMPPConnection
protected void throwConnectionExceptionOrNoResponse() throws java.io.IOException, org.jivesoftware.smack.SmackException.NoResponseException
throwConnectionExceptionOrNoResponse
in class org.jivesoftware.smack.XMPPConnection
java.io.IOException
org.jivesoftware.smack.SmackException.NoResponseException
protected void setServiceName(java.lang.String serviceName)
setServiceName
in class org.jivesoftware.smack.XMPPConnection
protected void serverRequiresBinding()
serverRequiresBinding
in class org.jivesoftware.smack.XMPPConnection
protected void setServiceCapsNode(java.lang.String node)
setServiceCapsNode
in class org.jivesoftware.smack.XMPPConnection
protected void serverSupportsSession()
serverSupportsSession
in class org.jivesoftware.smack.XMPPConnection
protected void setRosterVersioningSupported()
setRosterVersioningSupported
in class org.jivesoftware.smack.XMPPConnection
protected void serverSupportsAccountCreation()
serverSupportsAccountCreation
in class org.jivesoftware.smack.XMPPConnection
protected org.jivesoftware.smack.SASLAuthentication getSASLAuthentication()
getSASLAuthentication
in class org.jivesoftware.smack.XMPPConnection
protected org.jivesoftware.smack.ConnectionConfiguration getConfiguration()
getConfiguration
in class org.jivesoftware.smack.XMPPConnection