Class ModularXmppClientToServerConnection
- java.lang.Object
-
- org.jivesoftware.smack.AbstractXMPPConnection
-
- org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection
-
- All Implemented Interfaces:
XMPPConnection
public final class ModularXmppClientToServerConnection extends AbstractXMPPConnection
The superclass of Smack's Modular Connection Architecture.Note: Everything related to the modular connection architecture is currently considered experimental and should not be used in production. Use the mature
XMPPTCPConnectionif 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 Classes Modifier and Type Class Description static classModularXmppClientToServerConnection.AuthenticatedAndResourceBoundStateDescriptorstatic classModularXmppClientToServerConnection.AuthenticatedButUnboundStateDescriptorstatic classModularXmppClientToServerConnection.ConnectedButUnauthenticatedStateDescriptorstatic classModularXmppClientToServerConnection.DisconnectedStateDescriptorstatic classModularXmppClientToServerConnection.LookupRemoteConnectionEndpointsStateDescriptorstatic classModularXmppClientToServerConnection.ResourceBindingStateDescriptorstatic classModularXmppClientToServerConnection.ResourceBoundResultstatic classModularXmppClientToServerConnection.SaslAuthenticationStateDescriptorstatic classModularXmppClientToServerConnection.SaslAuthenticationSuccessResultstatic classModularXmppClientToServerConnection.Stats-
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, currentSmackException, currentXmppException, debugger, host, lastFeaturesReceived, outgoingStreamXmlEnvironment, port, reader, saslFeatureReceived, SMACK_REACTOR, streamFeatures, streamId, tlsHandled, user, wasAuthenticated, writer
-
-
Constructor Summary
Constructors Constructor Description ModularXmppClientToServerConnection(ModularXmppClientToServerConnectionConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConnectionStateMachineListener(ConnectionStateMachineListener connectionStateMachineListener)protected voidafterFeaturesReceived()protected voidconnectInternal()Abstract method that concrete subclasses of XMPPConnection need to implement to perform their way of XMPP connection establishment.ModularXmppClientToServerConnectionConfigurationgetConfiguration()Get the connection configuration used by this connection.<CM extends ModularXmppClientToServerConnectionModule<? extends ModularXmppClientToServerConnectionModuleDescriptor>>
CMgetConnectionModuleFor(Class<? extends ModularXmppClientToServerConnectionModuleDescriptor> descriptorClass)InetAddressgetLocalAddress()Returns the local address currently in use for this connection, ornullif this is invalid for the type of underlying connection.ModularXmppClientToServerConnection.StatsgetStats()protected AbstractStreamOpengetStreamOpen(DomainBareJid to, CharSequence from, String id, String lang)voidinstantShutdown()Performs an unclean disconnect and shutdown of the connection.booleanisSecureConnection()Returns true if the connection to the server has successfully negotiated encryption.booleanisUsingCompression()Returns true if network traffic is being compressed.protected voidloginInternal(String username, String password, Resourcepart resource)booleanremoveConnectionStateMachineListener(ConnectionStateMachineListener connectionStateMachineListener)protected voidsendInternal(TopLevelStreamElement element)protected voidsendNonBlockingInternal(TopLevelStreamElement element)protected voidshutdown()Shuts the current connection down.-
Methods inherited from class org.jivesoftware.smack.AbstractXMPPConnection
addAsyncStanzaListener, addConnectionListener, addMessageInterceptor, addOneTimeSyncCallback, addPresenceInterceptor, addStanzaInterceptor, 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, removeStanzaInterceptor, removeStanzaListener, removeStanzaSendingListener, removeSyncStanzaListener, schedule, sendAndWaitForResponse, sendAsync, sendAsync, sendIqRequestAndWaitForResponse, sendIqRequestAsync, sendIqRequestAsync, sendNonza, sendNonzaNonBlocking, sendStanza, sendStanzaNonBlocking, sendStreamOpen, setCurrentConnectionExceptionAndNotify, setFromMode, setMaxAsyncOperations, setParsingExceptionCallback, setReplyTimeout, setUnknownIqRequestReplyMode, setWasAuthenticated, throwAlreadyConnectedExceptionIfAppropriate, throwAlreadyLoggedInExceptionIfAppropriate, throwCurrentConnectionException, 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, getFeature, hasFeature
-
-
-
-
Constructor Detail
-
ModularXmppClientToServerConnection
public ModularXmppClientToServerConnection(ModularXmppClientToServerConnectionConfiguration configuration)
-
-
Method Detail
-
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:
loginInternalin classAbstractXMPPConnection- Throws:
XMPPExceptionSmackExceptionIOExceptionInterruptedException
-
sendInternal
protected void sendInternal(TopLevelStreamElement element) throws SmackException.NotConnectedException, InterruptedException
- Specified by:
sendInternalin classAbstractXMPPConnection- Throws:
SmackException.NotConnectedExceptionInterruptedException
-
sendNonBlockingInternal
protected void sendNonBlockingInternal(TopLevelStreamElement element) throws SmackException.NotConnectedException, SmackException.OutgoingQueueFullException
- Specified by:
sendNonBlockingInternalin classAbstractXMPPConnection- Throws:
SmackException.NotConnectedExceptionSmackException.OutgoingQueueFullException
-
shutdown
protected void shutdown()
Description copied from class:AbstractXMPPConnectionShuts the current connection down.- Specified by:
shutdownin classAbstractXMPPConnection
-
instantShutdown
public void instantShutdown()
Description copied from class:AbstractXMPPConnectionPerforms an unclean disconnect and shutdown of the connection. Does not send a closing stream stanza.- Specified by:
instantShutdownin classAbstractXMPPConnection
-
getConfiguration
public ModularXmppClientToServerConnectionConfiguration getConfiguration()
Description copied from class:AbstractXMPPConnectionGet the connection configuration used by this connection.- Overrides:
getConfigurationin classAbstractXMPPConnection- Returns:
- the connection configuration.
-
afterFeaturesReceived
protected void afterFeaturesReceived()
- Overrides:
afterFeaturesReceivedin classAbstractXMPPConnection
-
getStreamOpen
protected AbstractStreamOpen getStreamOpen(DomainBareJid to, CharSequence from, String id, String lang)
- Overrides:
getStreamOpenin classAbstractXMPPConnection
-
isUsingCompression
public boolean isUsingCompression()
Description copied from interface:XMPPConnectionReturns 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:
isUsingCompressionin interfaceXMPPConnection- Specified by:
isUsingCompressionin classAbstractXMPPConnection- Returns:
- true if network traffic is being compressed.
-
addConnectionStateMachineListener
public void addConnectionStateMachineListener(ConnectionStateMachineListener connectionStateMachineListener)
-
removeConnectionStateMachineListener
public boolean removeConnectionStateMachineListener(ConnectionStateMachineListener connectionStateMachineListener)
-
isSecureConnection
public boolean isSecureConnection()
Description copied from interface:XMPPConnectionReturns true if the connection to the server has successfully negotiated encryption.- Specified by:
isSecureConnectionin interfaceXMPPConnection- Specified by:
isSecureConnectionin classAbstractXMPPConnection- Returns:
- true if a secure connection to the server.
-
connectInternal
protected void connectInternal() throws SmackException, IOException, XMPPException, InterruptedException
Description copied from class:AbstractXMPPConnectionAbstract 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:
connectInternalin 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
public InetAddress getLocalAddress()
Description copied from interface:XMPPConnectionReturns the local address currently in use for this connection, ornullif this is invalid for the type of underlying connection.- Returns:
- the local address currently in use for this connection
-
getStats
public ModularXmppClientToServerConnection.Stats getStats()
-
-