Class Body
- java.lang.Object
-
- rocks.xmpp.extensions.httpbind.model.Body
-
- All Implemented Interfaces:
Comparable<Body>,LanguageElement,SessionOpen,StreamElement
public final class Body extends Object implements SessionOpen, Comparable<Body>
The implementation of the<body/>element in thehttp://jabber.org/protocol/httpbindnamespace.The natural ordering of this class is ordering by request ids (RID).
This class is immutable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBody.BuilderA builder for the body element.static classBody.ConditionThe implementation of the 'condition' attribute of the<body/>wrapper element, which indicates an error reported by the connection manager.static classBody.TypeThe implementation of the 'type' attribute of the<body/>element.
-
Field Summary
Fields Modifier and Type Field Description static StringNAMESPACEhttp://jabber.org/protocol/httpbindstatic StringXBOSH_NAMESPACEurn:xmpp:xbosh
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Body.Builderbuilder()Creates a builder for the body element.intcompareTo(Body o)Compares this body with another body by using the request id.booleanequals(Object other)StringgetAccept()The connection manager MAY include an 'accept' attribute in the session creation response element, to specify a comma-separated list of the content encodings it can decompress.LonggetAck()A client MAY include an 'ack' attribute (set to "1") to indicate that it will be using acknowledgements throughout the session and that the absence of an 'ack' attribute in any request is meaningful.StringgetAuthId()Gets the 'authid' attribute, which contains the value of the XMPP stream ID generated by the XMPP server.StringgetBoshVersion()This attribute specifies the highest version of the BOSH protocol that the client supports.List<Charset>getCharsets()The connection manager MAY inform the client which encodings it can convert by setting the optional 'charsets' attribute in the session creation response element to a space-separated list of encodings.Body.ConditiongetCondition()Gets a terminal binding condition.StringgetContent()Some clients are constrained to only accept HTTP responses with specific Content-Types (e.g., "text/html").JidgetFrom()The<body/>element of the first request MAY also possess a 'from' attribute, which specifies the originator of the first stream and which enables the connection manager to forward the originating entity's identity to the application server.ShortgetHold()This attribute informs the client about the maximum number of requests the connection manager will keep waiting at any one time during the session.StringgetId()Gets the session id.DurationgetInactivity()After receiving a response from the connection manager, if none of the client's requests are still being held by the connection manager (and if the session is not a Polling Session), the client SHOULD make a new request as soon as possible.StringgetKey()Gets the key used to protect insecure connections.LocalegetLanguage()Gets the language, i.e. the value of the 'xml:lang' attribute.DurationgetMaxPause()If the connection manager supports session pausing (see Inactivity) then it SHOULD advertise that to the client by including a 'maxpause' attribute in the session creation response element.StringgetNewKey()Gets the new key used to protect insecure connections.DurationgetPause()If a client encounters an exceptional temporary situation during which it will be unable to send requests to the connection manager for a period of time greater than the maximum inactivity period (e.g., while a runtime environment changes from one web page to another), and if the connection manager included a 'maxpause' attribute in its Session Creation Response, then the client MAY request a temporary increase to the maximum inactivity period by including a 'pause' attribute in a request.DurationgetPolling()This attribute specifies the shortest allowable polling interval (in seconds).LonggetReport()After receiving a request with an 'ack' value less than the 'rid' of the last request that it has already responded to, the connection manager MAY inform the client of the situation by sending its next response immediately instead of waiting until it has payloads to send to the client (e.g., if some time has passed since it responded).ShortgetRequests()This attribute enables the connection manager to limit the number of simultaneous requests the client makes (see Overactivity and Polling Sessions).LonggetRid()The<body/>element of every client request MUST possess a sequential request ID encapsulated via the 'rid' attribute.StringgetRoute()A connection manager MAY be configured to enable sessions with more than one server in different domains.StringgetSid()All requests after the first one MUST include a valid 'sid' attribute (provided by the connection manager in the Session Creation Response).StringgetStream()If a connection manager supports the multi-streams feature, it MUST include a 'stream' attribute in its Session Creation Response.DurationgetTime()After receiving a request with an 'ack' value less than the 'rid' of the last request that it has already responded to, the connection manager MAY inform the client of the situation by sending its next response immediately instead of waiting until it has payloads to send to the client (e.g., if some time has passed since it responded).JidgetTo()Gets the 'to' attribute.Body.TypegetType()The type of the body.URIgetUri()If the connection manager reports aBody.Condition.SEE_OTHER_URIerror condition, this method returns the URI.StringgetVersion()Gets the XMPP version.DurationgetWait()This attribute specifies the longest time (in seconds) that the connection manager is allowed to wait before responding to any request during the session.List<Object>getWrappedObjects()Gets an unmodifiable list of wrapped objects.inthashCode()booleanisRestart()If the client requests a stream restart.booleanisRestartLogic()If the connection manager supports stream restarts, it MUST advertise that fact by including a 'restartlogic' attribute (qualified by the 'urn:xmpp:xbosh' namespace) whose value is set to "true".StringtoString()
-
-
-
Field Detail
-
NAMESPACE
public static final String NAMESPACE
http://jabber.org/protocol/httpbind- See Also:
- Constant Field Values
-
XBOSH_NAMESPACE
public static final String XBOSH_NAMESPACE
urn:xmpp:xbosh- See Also:
- Constant Field Values
-
-
Method Detail
-
builder
public static Body.Builder builder()
Creates a builder for the body element.- Returns:
- The body.
-
getWrappedObjects
public final List<Object> getWrappedObjects()
Gets an unmodifiable list of wrapped objects.- Returns:
- The wrapped objects.
-
getUri
public final URI getUri()
If the connection manager reports aBody.Condition.SEE_OTHER_URIerror condition, this method returns the URI.- Returns:
- The URI.
- See Also:
Body.Condition.SEE_OTHER_URI
-
getAccept
public final String getAccept()
The connection manager MAY include an 'accept' attribute in the session creation response element, to specify a comma-separated list of the content encodings it can decompress. After receiving a session creation response with an 'accept' attribute, clients MAY include an HTTP Content-Encoding header in subsequent requests (indicating one of the encodings specified in the 'accept' attribute) and compress the bodies of the requests accordingly.- Returns:
- The comma-separated list of the content encodings.
-
getAck
public final Long getAck()
A client MAY include an 'ack' attribute (set to "1") to indicate that it will be using acknowledgements throughout the session and that the absence of an 'ack' attribute in any request is meaningful. When responding to a request that it has been holding, if the connection manager finds it has already received another request with a higher 'rid' attribute (typically while it was holding the first request), then it MAY acknowledge the reception to the client. The connection manager MAY set the 'ack' attribute of any response to the value of the highest 'rid' attribute it has received in the case where it has also received all requests with lower 'rid' values.- Returns:
- The acknowledged request.
- See Also:
getReport(),getTime()
-
getAuthId
public final String getAuthId()
Gets the 'authid' attribute, which contains the value of the XMPP stream ID generated by the XMPP server. This value is needed only by legacy XMPP clients in order to complete digest authentication using the obsolete Non-SASL Authentication (XEP-0078) protocol.- Returns:
- The 'authId' attribute.
-
getCharsets
public final List<Charset> getCharsets()
The connection manager MAY inform the client which encodings it can convert by setting the optional 'charsets' attribute in the session creation response element to a space-separated list of encodings.- Returns:
- The available charsets.
-
getCondition
public final Body.Condition getCondition()
Gets a terminal binding condition.- Returns:
- The condition.
- See Also:
getType(), 17.2 Terminal Binding Conditions
-
getContent
public final String getContent()
Some clients are constrained to only accept HTTP responses with specific Content-Types (e.g., "text/html"). The<body/>element of the first request MAY possess a 'content' attribute. This specifies the value of the HTTP Content-Type header that MUST appear in all the connection manager's responses during the session. If the client request does not possess a 'content' attribute, then the HTTP Content-Type header of responses MUST be "text/xml; charset=utf-8".- Returns:
- The content type.
-
getFrom
public final Jid getFrom()
The<body/>element of the first request MAY also possess a 'from' attribute, which specifies the originator of the first stream and which enables the connection manager to forward the originating entity's identity to the application server.- Specified by:
getFromin interfaceSessionOpen- Returns:
- The 'from' attribute.
-
getHold
public final Short getHold()
This attribute informs the client about the maximum number of requests the connection manager will keep waiting at any one time during the session. This value MUST NOT be greater than the value specified by the client in the session request. The client SHOULD set the 'hold' attribute to a value of "1".- Returns:
- The 'hold' attribute.
- See Also:
getRequests()
-
getInactivity
public final Duration getInactivity()
After receiving a response from the connection manager, if none of the client's requests are still being held by the connection manager (and if the session is not a Polling Session), the client SHOULD make a new request as soon as possible. In any case, if no requests are being held, the client MUST make a new request before the maximum inactivity period has expired. The length of this period (in seconds) is specified by the 'inactivity' attribute in the session creation response.- Returns:
- The inactivity period or null.
- See Also:
getPause(),getMaxPause(), 10. Inactivity
-
getKey
public final String getKey()
Gets the key used to protect insecure connections.- Returns:
- The key.
- See Also:
getNewKey(), 15. Protecting Insecure Sessions
-
getMaxPause
public final Duration getMaxPause()
If the connection manager supports session pausing (see Inactivity) then it SHOULD advertise that to the client by including a 'maxpause' attribute in the session creation response element. The value of the attribute indicates the maximum length of a temporary session pause (in seconds) that a client can request.- Returns:
- The maximal pause or null.
- See Also:
getPause(),getInactivity()
-
getNewKey
public final String getNewKey()
Gets the new key used to protect insecure connections.- Returns:
- The new key.
- See Also:
getKey()
-
getPause
public final Duration getPause()
If a client encounters an exceptional temporary situation during which it will be unable to send requests to the connection manager for a period of time greater than the maximum inactivity period (e.g., while a runtime environment changes from one web page to another), and if the connection manager included a 'maxpause' attribute in its Session Creation Response, then the client MAY request a temporary increase to the maximum inactivity period by including a 'pause' attribute in a request.- Returns:
- The 'pause' attribute value.
- See Also:
getMaxPause(),getInactivity()
-
getPolling
public final Duration getPolling()
This attribute specifies the shortest allowable polling interval (in seconds). This enables the client to not send empty request elements more often than desired.- Returns:
- The 'polling' attribute value or null.
-
getReport
public final Long getReport()
After receiving a request with an 'ack' value less than the 'rid' of the last request that it has already responded to, the connection manager MAY inform the client of the situation by sending its next response immediately instead of waiting until it has payloads to send to the client (e.g., if some time has passed since it responded). In this case it SHOULD include a 'report' attribute set to one greater than the 'ack' attribute it received from the client, and a 'time' attribute set to the number of milliseconds since it sent the response associated with the 'report' attribute.Upon reception of a response with 'report' and 'time' attributes, if the client has still not received the response associated with the request identifier specified by the 'report' attribute, then it MAY choose to resend the request associated with the missing response.
-
getRequests
public final Short getRequests()
This attribute enables the connection manager to limit the number of simultaneous requests the client makes (see Overactivity and Polling Sessions). The RECOMMENDED values are either "2" or one more than the value of the 'hold' attribute specified in the session request.- Returns:
- The 'requests' attribute value.
- See Also:
getHold()
-
getRid
public final Long getRid()
The<body/>element of every client request MUST possess a sequential request ID encapsulated via the 'rid' attribute.- Returns:
- The 'rid' attribute value.
-
getRoute
public final String getRoute()
A connection manager MAY be configured to enable sessions with more than one server in different domains. When requesting a session with such a "proxy" connection manager, a client SHOULD include a 'route' attribute that specifies the protocol, hostname, and port of the server with which it wants to communicate, formatted as "proto:host:port" (e.g., "xmpp:example.com:9999").- Returns:
- The 'route' attribute value.
-
getSid
public final String getSid()
All requests after the first one MUST include a valid 'sid' attribute (provided by the connection manager in the Session Creation Response). The initialization request is unique in that the<body/>element MUST NOT possess a 'sid' attribute.- Returns:
- The 'sid' attribute value.
-
getId
public final String getId()
Gets the session id.- Specified by:
getIdin interfaceSessionOpen- Returns:
- The session id.
- See Also:
getSid()
-
getStream
public final String getStream()
If a connection manager supports the multi-streams feature, it MUST include a 'stream' attribute in its Session Creation Response. If a client does not receive the 'stream' attribute then it MUST assume that the connection manager does not support the feature.- Returns:
- The 'stream' attribute value.
-
getTime
public final Duration getTime()
After receiving a request with an 'ack' value less than the 'rid' of the last request that it has already responded to, the connection manager MAY inform the client of the situation by sending its next response immediately instead of waiting until it has payloads to send to the client (e.g., if some time has passed since it responded). In this case it SHOULD include a 'report' attribute set to one greater than the 'ack' attribute it received from the client, and a 'time' attribute set to the number of milliseconds since it sent the response associated with the 'report' attribute.- Returns:
- The 'time' attribute value.
- See Also:
getReport(),getAck()
-
getTo
public final Jid getTo()
Description copied from interface:SessionOpenGets the 'to' attribute.- Specified by:
getToin interfaceSessionOpen- Returns:
- The 'to' attribute.
-
getType
public final Body.Type getType()
The type of the body.- Returns:
- The type.
- See Also:
getCondition()
-
getBoshVersion
public final String getBoshVersion()
This attribute specifies the highest version of the BOSH protocol that the client supports. The numbering scheme is "<major>.<minor>" (where the minor number MAY be incremented higher than a single digit, so it MUST be treated as a separate integer). Note: The 'ver' attribute should not be confused with the version of any protocol being transported.- Returns:
- The 'version' attribute value.
-
getWait
public final Duration getWait()
This attribute specifies the longest time (in seconds) that the connection manager is allowed to wait before responding to any request during the session. This enables the client to limit the delay before it discovers any network failure, and to prevent its HTTP/TCP connection from expiring due to inactivity.- Returns:
- The 'wait' attribute value.
-
getLanguage
public final Locale getLanguage()
Description copied from interface:LanguageElementGets the language, i.e. the value of the 'xml:lang' attribute.- Specified by:
getLanguagein interfaceLanguageElement- Returns:
- The language.
-
getVersion
public final String getVersion()
Gets the XMPP version.- Specified by:
getVersionin interfaceSessionOpen- Returns:
- The XMPP version.
-
isRestart
public final boolean isRestart()
If the client requests a stream restart.- Returns:
- The 'restart' attribute value.
-
isRestartLogic
public final boolean isRestartLogic()
If the connection manager supports stream restarts, it MUST advertise that fact by including a 'restartlogic' attribute (qualified by the 'urn:xmpp:xbosh' namespace) whose value is set to "true".- Returns:
- The 'restartlogic' attribute value.
-
compareTo
public final int compareTo(Body o)
Compares this body with another body by using the request id. Null bodies are sorted last, while null RIDs are sorted first (as it may indicate a session creation request).- Specified by:
compareToin interfaceComparable<Body>- Parameters:
o- The body.- Returns:
- The comparison result.
-
-