Class StreamManager
java.lang.Object
org.jivesoftware.openfire.streammanagement.StreamManager
XEP-0198 Stream Manager.
Handles client/server messages acknowledgement.
- Author:
- jonnyheavey
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic SystemProperty<Boolean>static SystemProperty<Boolean>static SystemProperty<Boolean>static SystemProperty<Boolean>static final StringStanza namespacesstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTerminationDelegate(TerminationDelegate delegate) Adds a new delegate that can determine if a detached session can be terminated.org.dom4j.ElementenableAndBuildElement(String namespace, boolean resume) Enables stream management, returning the<enabled/>element rather than sending it.voidCalled when a session receives a closing stream tag, this prevents the session from being detached.booleanReturns true if a stream is resumable.Returns a defensive copy of all delegates that can determine if a detached session can be terminated.voidIncrements the count of stanzas processed by the server since Stream Management was enabled.booleanDetermines whether Stream Management enabled for session this manager belongs to.static booleanvoidonClose(PacketRouter router, org.xmpp.packet.JID serverAddress) voidonResume(org.xmpp.packet.JID serverAddress, long h) voidprocess(org.dom4j.Element element) Processes a stream management element.processSasl2Resume(ResumeRequest request) Attempts to process (validate and perform) an inline SASL2 (XEP-0388) resume request, as defined by XEP-0198 § 9.2 ("Inline Stream Resumption").voidredeliverUnackedStanzas(org.xmpp.packet.JID serverAddress, long h) Processes the client's acknowledgement of 'h' as reported in its (traditional or inline SASL2) resume request, and retransmits any stanzas that remain unacknowledged after that.voidremoveTerminationDelegate(TerminationDelegate delegate) Removes a delegate that can determine if a detached session can be terminated.static org.dom4j.ElementReturns the element that advertises support for inline stream resumption in the<inline/>element of the SASL2 stream feature, as defined in XEP-0198 § 9.2.voidSends XEP-0198 acknowledgement <a /> to client from servervoidsentStanza(org.xmpp.packet.Packet packet) Registers that Openfire sends a stanza to the client (which is expected to be acknowledged later).
-
Field Details
-
LOCATION_ENABLED
-
LOCATION_TERMINATE_OTHERS_ENABLED
-
MAX_SERVER_ENABLED
-
ACTIVE
-
NAMESPACE_V2
Stanza namespaces- See Also:
-
NAMESPACE_V3
- See Also:
-
-
Constructor Details
-
StreamManager
-
-
Method Details
-
isStreamManagementActive
public static boolean isStreamManagementActive() -
getResume
public boolean getResume()Returns true if a stream is resumable.- Returns:
- True if a stream is resumable.
-
process
public void process(org.dom4j.Element element) Processes a stream management element. Inline resume requests, nested in a SASL2element, are not processed here; see processSasl2Resume(ResumeRequest) - Parameters:
element- The stream management element to be processed.
-
enableAndBuildElement
@Nonnull public org.dom4j.Element enableAndBuildElement(String namespace, boolean resume) throws StreamManagementException Enables stream management, returning the<enabled/>element rather than sending it. Leaving delivery to the caller allows an inline caller to embed the element in its enclosing response, as XEP-0198 § 9.1 requires of a Bind2 inline request.- Parameters:
namespace- the SM namespace to useresume- whether the client requests a resumable session- Returns:
- the
<enabled/>element - Throws:
StreamManagementException- when stream management could not be enabled, carrying the condition to report
-
processSasl2Resume
Attempts to process (validate and perform) an inline SASL2 (XEP-0388) resume request, as defined by XEP-0198 § 9.2 ("Inline Stream Resumption"). UnlikeprocessResume(ResumeRequest), this does not write its response to the connection. Instead, the outcome is returned as aSasl2ResumeResult, for the caller to embed in the SASL2<success/>response that it is constructing. This method is invoked on the stream manager of the temporary session that is negotiating the SASL2 authentication. On success, the connection has been transferred to the resumed session, which is the session that the<success/>must be delivered to. Having delivered it, the caller completes the resumption by invokingLocalSession.completeSasl2Resume(long)on that session: everything it delivers must follow the resumption confirmation on the wire, which is why it cannot be done here. On failure, no state is changed: the temporary session remains usable, and the caller is expected to proceed with resource binding, reporting the returned<failed/>element alongside the outcome of that bind.- Parameters:
request- the parsed inline resume request (cannot be null).- Returns:
- the outcome of the resume attempt.
-
formalClose
public void formalClose()Called when a session receives a closing stream tag, this prevents the session from being detached. -
sendServerAcknowledgement
public void sendServerAcknowledgement()Sends XEP-0198 acknowledgement <a /> to client from server -
sentStanza
public void sentStanza(org.xmpp.packet.Packet packet) Registers that Openfire sends a stanza to the client (which is expected to be acknowledged later).- Parameters:
packet- The stanza that is sent.
-
onClose
-
onResume
public void onResume(org.xmpp.packet.JID serverAddress, long h) -
redeliverUnackedStanzas
public void redeliverUnackedStanzas(@Nonnull org.xmpp.packet.JID serverAddress, long h) Processes the client's acknowledgement of 'h' as reported in its (traditional or inline SASL2) resume request, and retransmits any stanzas that remain unacknowledged after that. This is the second half of whatonResume(JID, long)does for the traditional resume flow. It is split out so that the inline SASL2 resume flow can defer this until after it has delivered its own response (typically, the SASL2<success/>that embeds the<resumed/>element built bybuildResumedElement()), handled byLocalSession.completeSasl2Resume(long).- Parameters:
serverAddress- this server's bare-domain address, used to stamp delay information on redelivered stanzas.h- the sequence number of the last handled stanza, as reported by the client that is resuming.
-
isEnabled
public boolean isEnabled()Determines whether Stream Management enabled for session this manager belongs to.- Returns:
- true when stream management is enabled, otherwise false.
-
incrementServerProcessedStanzas
public void incrementServerProcessedStanzas()Increments the count of stanzas processed by the server since Stream Management was enabled. -
getTerminationDelegates
Returns a defensive copy of all delegates that can determine if a detached session can be terminated.- Returns:
- all delegates that can determine if a detached session can be terminated.
-
addTerminationDelegate
Adds a new delegate that can determine if a detached session can be terminated. When no such delegate is registered for a session, the server default behavior will determine if a detached session can be terminated. This method will add delegates, unless the new delegate is equal to a previously registered delegate. In such case, this method will silently ignore the invocation.- Parameters:
delegate- the delegate to register with the session
-
removeTerminationDelegate
Removes a delegate that can determine if a detached session can be terminated. When no such delegate is registered for a session, the server default behavior will determine if a detached session can be terminated. This method will silently ignore an invocation to remove a delegate that was not registered with the session.- Parameters:
delegate- the delegate to register with the session
-
sasl2InlineFeatureElement
@Nonnull public static org.dom4j.Element sasl2InlineFeatureElement()Returns the element that advertises support for inline stream resumption in the<inline/>element of the SASL2 stream feature, as defined in XEP-0198 § 9.2. Note that this is distinct from the Bind2 inline feature (XEP-0198 § 9.1) that allows a client to enable stream management as part of a resource bind: that one is advertised throughBind2Request.featureElement().- Returns:
- the
<sm/>feature element.
-