public class XMPPTCPConnection
extends org.jivesoftware.smack.AbstractXMPPConnection
XMPPConnection| Modifier and Type | Class and Description |
|---|---|
protected class |
XMPPTCPConnection.PacketReader |
protected class |
XMPPTCPConnection.PacketWriter |
| Modifier and Type | Field and Description |
|---|---|
protected XMPPTCPConnection.PacketReader |
packetReader
Protected access level because of unit test purposes
|
protected XMPPTCPConnection.PacketWriter |
packetWriter
Protected access level because of unit test purposes
|
authenticated, collectors, compressionHandler, config, connectionCounterValue, connectionListeners, connectionLock, debugger, host, interceptors, lastFeaturesReceived, port, reader, recvListeners, saslAuthentication, saslFeatureReceived, sendListeners, streamFeatures, user, wasAuthenticated, writer| 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 |
|---|---|
org.jivesoftware.smack.PacketListener |
addIdStanzaAcknowledgedListener(java.lang.String id,
org.jivesoftware.smack.PacketListener listener) |
boolean |
addRequestAckPredicate(org.jivesoftware.smack.filter.PacketFilter predicate) |
void |
addStanzaAcknowledgedListener(org.jivesoftware.smack.PacketListener listener) |
protected void |
afterFeaturesReceived() |
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() |
void |
instantShutdown()
Performs an unclean disconnect and shutdown of the connection.
|
boolean |
isAuthenticated() |
boolean |
isConnected() |
boolean |
isDisconnectedButSmResumptionPossible() |
boolean |
isSecureConnection() |
boolean |
isSmAvailable() |
boolean |
isSmEnabled() |
boolean |
isSmResumptionPossible() |
boolean |
isSocketClosed() |
boolean |
isUsingCompression() |
void |
login(java.lang.String username,
java.lang.String password,
java.lang.String resource) |
void |
loginAnonymously() |
void |
removeAllIdStanzaAcknowledgedListeners() |
void |
removeAllRequestAckPredicates() |
void |
removeAllStanzaAcknowledgedListeners() |
org.jivesoftware.smack.PacketListener |
removeIdStanzaAcknowledgedListener(java.lang.String id) |
boolean |
removeRequestAckPredicate(org.jivesoftware.smack.filter.PacketFilter predicate) |
boolean |
removeStanzaAcknowledgedListener(org.jivesoftware.smack.PacketListener listener) |
void |
requestSmAcknowledgement() |
void |
send(org.jivesoftware.smack.packet.PlainStreamElement element) |
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
|
void |
setPreferredResumptionTime(int resumptionTime)
Set the preferred resumption time in seconds.
|
void |
setUseStreamManagement(boolean useSm) |
static void |
setUseStreamManagementDefault(boolean useSmDefault) |
static void |
setUseStreamManagementResumptiodDefault(boolean useSmResupmptionDefault) |
void |
setUseStreamManagementResumption(boolean useSmResumption) |
protected void |
setWriter(java.io.Writer writer)
For unit testing purposes
|
protected void |
shutdown()
Shuts the current connection down.
|
addConnectionListener, addPacketInterceptor, addPacketListener, addPacketSendingListener, afterSuccessfulLogin, bindResourceAndEstablishSession, callConnectionAuthenticatedListener, callConnectionClosedOnErrorListener, callConnectionConnectedListener, connect, createPacketCollector, createPacketCollectorAndSend, disconnect, disconnect, finalize, getConfiguration, getConnectionCounter, getConnectionCreationListeners, getConnectionListeners, getConnectionLock, getFeature, getFromMode, getHost, getLastStanzaReceived, getPacketCollectors, getPacketInterceptors, getPacketReplyTimeout, getPacketSendingListeners, getPort, getRoster, getRosterStore, getSASLAuthentication, getServiceName, hasFeature, initDebugger, isAnonymous, isRosterLoadedAtLogin, login, maybeResolveDns, parseFeatures, processPacket, removeConnectionListener, removePacketCollector, removePacketInterceptor, removePacketListener, removePacketSendingListener, reportStanzaReceived, sendIqWithResponseCallback, sendIqWithResponseCallback, sendIqWithResponseCallback, sendPacket, sendStanzaWithResponseCallback, sendStanzaWithResponseCallback, sendStanzaWithResponseCallback, setFromMode, setLoginInfo, setPacketReplyTimeout, setServiceName, setWasAuthenticatedprotected XMPPTCPConnection.PacketWriter packetWriter
protected XMPPTCPConnection.PacketReader packetReader
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.XMPPConnectiongetConnectionID in class org.jivesoftware.smack.AbstractXMPPConnectionpublic java.lang.String getUser()
getUser in interface org.jivesoftware.smack.XMPPConnectiongetUser in class org.jivesoftware.smack.AbstractXMPPConnectionpublic 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,
java.io.IOException
login in class org.jivesoftware.smack.AbstractXMPPConnectionorg.jivesoftware.smack.XMPPExceptionorg.jivesoftware.smack.SmackExceptionjava.io.IOExceptionpublic void loginAnonymously()
throws org.jivesoftware.smack.XMPPException,
org.jivesoftware.smack.SmackException,
java.io.IOException
loginAnonymously in class org.jivesoftware.smack.AbstractXMPPConnectionorg.jivesoftware.smack.XMPPExceptionorg.jivesoftware.smack.SmackExceptionjava.io.IOExceptionpublic boolean isConnected()
isConnected in interface org.jivesoftware.smack.XMPPConnectionisConnected in class org.jivesoftware.smack.AbstractXMPPConnectionpublic boolean isSecureConnection()
isSecureConnection in interface org.jivesoftware.smack.XMPPConnectionisSecureConnection in class org.jivesoftware.smack.AbstractXMPPConnectionpublic boolean isSocketClosed()
public boolean isAuthenticated()
isAuthenticated in interface org.jivesoftware.smack.XMPPConnectionisAuthenticated in class org.jivesoftware.smack.AbstractXMPPConnectionprotected void shutdown()
shutdown in class org.jivesoftware.smack.AbstractXMPPConnectionpublic void instantShutdown()
public void send(org.jivesoftware.smack.packet.PlainStreamElement element)
throws org.jivesoftware.smack.SmackException.NotConnectedException
send in interface org.jivesoftware.smack.XMPPConnectionsend in class org.jivesoftware.smack.AbstractXMPPConnectionorg.jivesoftware.smack.SmackException.NotConnectedExceptionprotected void sendPacketInternal(org.jivesoftware.smack.packet.Packet packet)
throws org.jivesoftware.smack.SmackException.NotConnectedException
sendPacketInternal in class org.jivesoftware.smack.AbstractXMPPConnectionorg.jivesoftware.smack.SmackException.NotConnectedExceptionpublic boolean isUsingCompression()
isUsingCompression in interface org.jivesoftware.smack.XMPPConnectionisUsingCompression in class org.jivesoftware.smack.AbstractXMPPConnectionprotected 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.AbstractXMPPConnectionorg.jivesoftware.smack.XMPPException - if an error occurs while trying to establish the connection.org.jivesoftware.smack.SmackExceptionjava.io.IOExceptionprotected void setWriter(java.io.Writer writer)
writer - protected void afterFeaturesReceived()
throws org.jivesoftware.smack.SmackException.SecurityRequiredException,
org.jivesoftware.smack.SmackException.NotConnectedException
afterFeaturesReceived in class org.jivesoftware.smack.AbstractXMPPConnectionorg.jivesoftware.smack.SmackException.SecurityRequiredExceptionorg.jivesoftware.smack.SmackException.NotConnectedExceptionpublic static void setUseStreamManagementDefault(boolean useSmDefault)
public static void setUseStreamManagementResumptiodDefault(boolean useSmResupmptionDefault)
public void setUseStreamManagement(boolean useSm)
public void setUseStreamManagementResumption(boolean useSmResumption)
public void setPreferredResumptionTime(int resumptionTime)
resumptionTime - the preferred resumption time in secondspublic boolean addRequestAckPredicate(org.jivesoftware.smack.filter.PacketFilter predicate)
public boolean removeRequestAckPredicate(org.jivesoftware.smack.filter.PacketFilter predicate)
public void removeAllRequestAckPredicates()
public void requestSmAcknowledgement()
throws StreamManagementException.StreamManagementNotEnabledException,
org.jivesoftware.smack.SmackException.NotConnectedException
StreamManagementException.StreamManagementNotEnabledExceptionorg.jivesoftware.smack.SmackException.NotConnectedExceptionpublic void addStanzaAcknowledgedListener(org.jivesoftware.smack.PacketListener listener)
public boolean removeStanzaAcknowledgedListener(org.jivesoftware.smack.PacketListener listener)
public void removeAllStanzaAcknowledgedListeners()
public org.jivesoftware.smack.PacketListener addIdStanzaAcknowledgedListener(java.lang.String id,
org.jivesoftware.smack.PacketListener listener)
public org.jivesoftware.smack.PacketListener removeIdStanzaAcknowledgedListener(java.lang.String id)
public void removeAllIdStanzaAcknowledgedListeners()
public boolean isSmAvailable()
public boolean isSmEnabled()
public boolean isDisconnectedButSmResumptionPossible()
public boolean isSmResumptionPossible()