Package org.jivesoftware.smack.bosh
Class XMPPBOSHConnection
java.lang.Object
org.jivesoftware.smack.AbstractXMPPConnection
org.jivesoftware.smack.bosh.XMPPBOSHConnection
- All Implemented Interfaces:
XMPPConnection
Creates a connection to an XMPP server via HTTP binding.
This is specified in the XEP-0206: XMPP Over BOSH.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jivesoftware.smack.AbstractXMPPConnection
AbstractXMPPConnection.InterceptorWrapper, AbstractXMPPConnection.ListenerWrapper, AbstractXMPPConnection.SyncPointStateNested classes/interfaces inherited from interface org.jivesoftware.smack.XMPPConnection
XMPPConnection.FromMode -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe BOSH namespace from XEP-0124.protected StringThe session ID for the BOSH session with the connection manager.static final StringThe XMPP Over Bosh namespace.Fields inherited from class org.jivesoftware.smack.AbstractXMPPConnection
ASYNC_BUT_ORDERED, authenticated, authenticatedConnectionInitiallyEstablishedTimestamp, closingStreamReceived, compressionHandler, connected, connectionCounterValue, connectionListeners, connectionLock, debugger, host, lastFeaturesReceived, outgoingStreamXmlEnvironment, port, reader, saslFeatureReceived, SMACK_REACTOR, streamFeatures, streamId, tlsHandled, user, wasAuthenticated, writer -
Constructor Summary
ConstructorsConstructorDescriptionXMPPBOSHConnection(String username, String password, boolean https, String host, int port, String filePath, DomainBareJid xmppServiceDomain) Create a HTTP Binding connection to an XMPP server.XMPPBOSHConnection(BOSHConfiguration config) Create a HTTP Binding connection to an XMPP server. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidHook for subclasses right after successful SASL authentication.protected voidAbstract method that concrete subclasses of XMPPConnection need to implement to perform their way of XMPP connection establishment.Returns the local address currently in use for this connection, ornullif this is invalid for the type of underlying connection.protected voidInitialize the SmackDebugger which allows to log and debug XML traffic.voidPerforms an unclean disconnect and shutdown of the connection.booleanReturns true if the connection to the server has successfully negotiated encryption.booleanReturns true if network traffic is being compressed.protected voidloginInternal(String username, String password, Resourcepart resource) protected voidsend(org.igniterealtime.jbosh.ComposableBody body) Send a HTTP request to the connection manager with the provided body element.protected voidsendInternal(TopLevelStreamElement element) protected voidprotected voidshutdown()Shuts the current connection down.Methods inherited from class org.jivesoftware.smack.AbstractXMPPConnection
addAsyncStanzaListener, addConnectionListener, addMessageInterceptor, addOneTimeSyncCallback, addPresenceInterceptor, addStanzaListener, addStanzaSendingListener, addStreamFeature, addSyncStanzaListener, afterFeaturesReceived, afterSuccessfulLogin, asyncGo, asyncGoLimited, authenticate, bindResourceAndEstablishSession, buildNonzaCallback, callConnectionAuthenticatedListener, callConnectionConnectedListener, callConnectionConnectingListener, connect, createStanzaCollector, createStanzaCollector, createStanzaCollectorAndSend, createStanzaCollectorAndSend, disconnect, disconnect, firePacketSendingListeners, getAuthenticatedConnectionInitiallyEstablishedTimestamp, getConfiguration, getConnectionCounter, getConnectionLock, getFeature, getFromMode, getHost, getLastStanzaReceived, getParsingExceptionCallback, getPort, getReactor, getReplyTimeout, getSmackTlsContext, getStanzaFactory, getStreamId, getStreamOpen, getUsedSaslMechansism, getUser, getXMPPServiceDomain, hasCurrentConnectionException, hasFeature, 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, waitForConditionOrThrowConnectionExceptionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jivesoftware.smack.XMPPConnection
getFeature, hasFeature
-
Field Details
-
XMPP_BOSH_NS
The XMPP Over Bosh namespace.- See Also:
-
BOSH_URI
The BOSH namespace from XEP-0124.- See Also:
-
sessionID
The session ID for the BOSH session with the connection manager.
-
-
Constructor Details
-
XMPPBOSHConnection
public XMPPBOSHConnection(String username, String password, boolean https, String host, int port, String filePath, DomainBareJid xmppServiceDomain) Create a HTTP Binding connection to an XMPP server.- Parameters:
username- the username to use.password- the password to use.https- true if you want to use SSL (e.g. false for http://domain.lt:7070/http-bind).host- the hostname or IP address of the connection manager (e.g. domain.lt for http://domain.lt:7070/http-bind).port- the port of the connection manager (e.g. 7070 for http://domain.lt:7070/http-bind).filePath- the file which is described by the URL (e.g. /http-bind for http://domain.lt:7070/http-bind).xmppServiceDomain- the XMPP service name (e.g. domain.lt for the user alice@domain.lt)
-
XMPPBOSHConnection
Create a HTTP Binding connection to an XMPP server.- Parameters:
config- The configuration which is used for this connection.
-
-
Method Details
-
connectInternal
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.InterruptedException- if the calling thread was interrupted.
-
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.
-
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.
-
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
-
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
-
shutdown
Description copied from class:AbstractXMPPConnectionShuts the current connection down.- Specified by:
shutdownin classAbstractXMPPConnection
-
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
-
send
protected void send(org.igniterealtime.jbosh.ComposableBody body) throws org.igniterealtime.jbosh.BOSHException Send a HTTP request to the connection manager with the provided body element.- Parameters:
body- the body which will be sent.- Throws:
org.igniterealtime.jbosh.BOSHException- if an BOSH (Bidirectional-streams Over Synchronous HTTP, XEP-0124) related error occurs
-
initDebugger
Initialize the SmackDebugger which allows to log and debug XML traffic.- Overrides:
initDebuggerin classAbstractXMPPConnection
-
afterSaslAuthenticationSuccess
protected void afterSaslAuthenticationSuccess() throws SmackException.NotConnectedException, InterruptedException, SmackException.SmackWrappedExceptionDescription copied from class:AbstractXMPPConnectionHook for subclasses right after successful SASL authentication. RFC 6120 ยง 6.4.6. specifies a that the initiating entity, needs to initiate a new stream in this case. But some transports, like BOSH, requires a special handling.Note that we can not reset XMPPTCPConnection's parser here, because this method is invoked by the thread calling
AbstractXMPPConnection.login(), but the parser reset has to be done within the reader thread.- Overrides:
afterSaslAuthenticationSuccessin classAbstractXMPPConnection- Throws:
SmackException.NotConnectedException- if the XMPP connection is not connected.InterruptedException- if the calling thread was interrupted.SmackException.SmackWrappedException- in case of an exception.
-