Class ModularXmppClientToServerConnection
- All Implemented Interfaces:
XMPPConnection
Note: Everything related to the modular connection architecture is currently considered experimental and
should not be used in production. Use the mature XMPPTCPConnection
if you do not feel adventurous.
Smack's modular connection architecture allows to extend a XMPP c2s (client-to-server) connection with additional functionality by adding modules. Those modules extend the Finite State Machine (FSM) within the connection with new states. Connection modules can either be
- Transports
- Extensions
Transports bind the XMPP XML stream to an underlying transport like TCP, WebSockets, BOSH, and allow for the different particularities of transports like DirectTLS (XEP-0368). This eventually means that a single transport module can implement multiple transport mechanisms. For example the TCP transport module implements the RFC6120 TCP and the XEP-0368 direct TLS TCP transport bindings.
Extensions allow for a richer functionality of the connection. Those include
- Compression
- zlib ([XEP-0138](https://xmpp.org/extensions/xep-0138.html))
- [Efficient XML Interchange (EXI)](https://www.w3.org/TR/exi/)
- Instant Stream Resumption ([XEP-0397](https://xmpp.org/extensions/xep-0397.html)
- Bind2
- Stream Management
Connection modules are plugged into the the modular connection via their constructor. and they usually declare backwards edges to some common, generic connection state of the FSM.
Modules and states always have an accompanying *descriptor* type. `ModuleDescriptor` and `StateDescriptor` exist without an connection instance. They describe the module and state metadata, while their modules and states are Instantiated once a modular connection is instantiated.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
static final class
static final class
static class
static final class
static final class
static final class
static final class
static final class
static final class
Nested classes/interfaces inherited from class org.jivesoftware.smack.AbstractXMPPConnection
AbstractXMPPConnection.InterceptorWrapper, AbstractXMPPConnection.ListenerWrapper, AbstractXMPPConnection.SyncPointState
Nested classes/interfaces inherited from interface org.jivesoftware.smack.XMPPConnection
XMPPConnection.FromMode
-
Field Summary
Fields inherited from class org.jivesoftware.smack.AbstractXMPPConnection
ASYNC_BUT_ORDERED, authenticated, authenticatedConnectionInitiallyEstablishedTimestamp, closingStreamReceived, compressionHandler, config, connected, connectionCounterValue, connectionListeners, connectionLock, debugger, host, lastFeaturesReceived, outgoingStreamXmlEnvironment, port, reader, saslFeatureReceived, SMACK_REACTOR, streamFeatures, streamId, tlsHandled, user, wasAuthenticated, writer
-
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConnectionStateMachineListener
(ConnectionStateMachineListener connectionStateMachineListener) protected void
protected void
Abstract method that concrete subclasses of XMPPConnection need to implement to perform their way of XMPP connection establishment.Get the connection configuration used by this connection.<CM extends ModularXmppClientToServerConnectionModule<? extends ModularXmppClientToServerConnectionModuleDescriptor>>
CMgetConnectionModuleFor
(Class<? extends ModularXmppClientToServerConnectionModuleDescriptor> descriptorClass) Returns the local address currently in use for this connection, ornull
if this is invalid for the type of underlying connection.getStats()
protected AbstractStreamOpen
getStreamOpen
(DomainBareJid to, CharSequence from, String id, String lang) void
Performs an unclean disconnect and shutdown of the connection.boolean
Returns true if the connection to the server has successfully negotiated encryption.boolean
Returns true if network traffic is being compressed.protected void
loginInternal
(String username, String password, Resourcepart resource) boolean
removeConnectionStateMachineListener
(ConnectionStateMachineListener connectionStateMachineListener) protected void
sendInternal
(TopLevelStreamElement element) protected void
protected void
shutdown()
Shuts the current connection down.Methods inherited from class org.jivesoftware.smack.AbstractXMPPConnection
addAsyncStanzaListener, addConnectionListener, addMessageInterceptor, addOneTimeSyncCallback, addPresenceInterceptor, addStanzaListener, addStanzaSendingListener, addStreamFeature, addSyncStanzaListener, afterSaslAuthenticationSuccess, afterSuccessfulLogin, asyncGo, asyncGoLimited, authenticate, bindResourceAndEstablishSession, buildNonzaCallback, callConnectionAuthenticatedListener, callConnectionConnectedListener, callConnectionConnectingListener, connect, createStanzaCollector, createStanzaCollector, createStanzaCollectorAndSend, createStanzaCollectorAndSend, disconnect, disconnect, firePacketSendingListeners, getAuthenticatedConnectionInitiallyEstablishedTimestamp, getConnectionCounter, getConnectionLock, getFeature, getFromMode, getHost, getLastStanzaReceived, getParsingExceptionCallback, getPort, getReactor, getReplyTimeout, getSmackTlsContext, getStanzaFactory, getStreamId, getUsedSaslMechansism, getUser, getXMPPServiceDomain, hasCurrentConnectionException, hasFeature, initDebugger, initState, invokeStanzaCollectorsAndNotifyRecvListeners, isAnonymous, isAuthenticated, isConnected, isSaslAuthenticated, login, login, login, notifyConnectionError, notifyWaitingThreads, onStreamOpen, parseAndProcessNonza, parseAndProcessStanza, parseFeatures, parseFeaturesAndNotify, processStanza, registerIQRequestHandler, removeAsyncStanzaListener, removeConnectionListener, removeMessageInterceptor, removePresenceInterceptor, removeStanzaCollector, removeStanzaListener, removeStanzaSendingListener, removeSyncStanzaListener, schedule, sendAndWaitForResponse, sendAsync, sendAsync, sendIqRequestAndWaitForResponse, sendIqRequestAsync, sendIqRequestAsync, sendNonza, sendNonzaNonBlocking, sendStanza, sendStanzaNonBlocking, sendStreamOpen, setCurrentConnectionExceptionAndNotify, setFromMode, setMaxAsyncOperations, setParsingExceptionCallback, setReplyTimeout, setUnknownIqRequestReplyMode, setWasAuthenticated, throwAlreadyConnectedExceptionIfAppropriate, throwAlreadyLoggedInExceptionIfAppropriate, throwNotConnectedExceptionIfAppropriate, throwNotConnectedExceptionIfAppropriate, toString, trySendStanza, trySendStanza, unregisterIQRequestHandler, unregisterIQRequestHandler, updateOutgoingStreamXmlEnvironmentOnStreamOpen, waitFor, waitForClosingStreamTagFromServer, waitForConditionOrThrowConnectionException
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jivesoftware.smack.XMPPConnection
getFeature, hasFeature
-
Constructor Details
-
ModularXmppClientToServerConnection
public ModularXmppClientToServerConnection(ModularXmppClientToServerConnectionConfiguration configuration)
-
-
Method Details
-
getConnectionModuleFor
public <CM extends ModularXmppClientToServerConnectionModule<? extends ModularXmppClientToServerConnectionModuleDescriptor>> CM getConnectionModuleFor(Class<? extends ModularXmppClientToServerConnectionModuleDescriptor> descriptorClass) -
loginInternal
protected void loginInternal(String username, String password, Resourcepart resource) throws XMPPException, SmackException, IOException, InterruptedException - Specified by:
loginInternal
in classAbstractXMPPConnection
- Throws:
XMPPException
SmackException
IOException
InterruptedException
-
sendInternal
protected void sendInternal(TopLevelStreamElement element) throws SmackException.NotConnectedException, InterruptedException - Specified by:
sendInternal
in classAbstractXMPPConnection
- Throws:
SmackException.NotConnectedException
InterruptedException
-
sendNonBlockingInternal
protected void sendNonBlockingInternal(TopLevelStreamElement element) throws SmackException.NotConnectedException, SmackException.OutgoingQueueFullException - Specified by:
sendNonBlockingInternal
in classAbstractXMPPConnection
- Throws:
SmackException.NotConnectedException
SmackException.OutgoingQueueFullException
-
shutdown
Description copied from class:AbstractXMPPConnection
Shuts the current connection down.- Specified by:
shutdown
in classAbstractXMPPConnection
-
instantShutdown
Description copied from class:AbstractXMPPConnection
Performs an unclean disconnect and shutdown of the connection. Does not send a closing stream stanza.- Specified by:
instantShutdown
in classAbstractXMPPConnection
-
getConfiguration
Description copied from class:AbstractXMPPConnection
Get the connection configuration used by this connection.- Overrides:
getConfiguration
in classAbstractXMPPConnection
- Returns:
- the connection configuration.
-
afterFeaturesReceived
- Overrides:
afterFeaturesReceived
in classAbstractXMPPConnection
-
getStreamOpen
protected AbstractStreamOpen getStreamOpen(DomainBareJid to, CharSequence from, String id, String lang) - Overrides:
getStreamOpen
in classAbstractXMPPConnection
-
isUsingCompression
Description copied from interface:XMPPConnection
Returns true if network traffic is being compressed. When using stream compression network traffic can be reduced up to 90%. Therefore, stream compression is ideal when using a slow speed network connection. However, the server will need to use more CPU time in order to un/compress network data so under high load the server performance might be affected.- Specified by:
isUsingCompression
in interfaceXMPPConnection
- Specified by:
isUsingCompression
in classAbstractXMPPConnection
- Returns:
- true if network traffic is being compressed.
-
addConnectionStateMachineListener
public void addConnectionStateMachineListener(ConnectionStateMachineListener connectionStateMachineListener) -
removeConnectionStateMachineListener
public boolean removeConnectionStateMachineListener(ConnectionStateMachineListener connectionStateMachineListener) -
isSecureConnection
Description copied from interface:XMPPConnection
Returns true if the connection to the server has successfully negotiated encryption.- Specified by:
isSecureConnection
in interfaceXMPPConnection
- Specified by:
isSecureConnection
in classAbstractXMPPConnection
- Returns:
- true if a secure connection to the server.
-
connectInternal
protected void connectInternal() throws SmackException, IOException, XMPPException, InterruptedExceptionDescription copied from class:AbstractXMPPConnection
Abstract method that concrete subclasses of XMPPConnection need to implement to perform their way of XMPP connection establishment. Implementations are required to perform an automatic login if the previous connection state was logged (authenticated).- Specified by:
connectInternal
in classAbstractXMPPConnection
- Throws:
SmackException
- if Smack detected an exceptional situation.IOException
- if an I/O error occurred.XMPPException
- if an XMPP protocol error was received.InterruptedException
- if the calling thread was interrupted.
-
getLocalAddress
Description copied from interface:XMPPConnection
Returns the local address currently in use for this connection, ornull
if this is invalid for the type of underlying connection.- Returns:
- the local address currently in use for this connection
-
getStats
-