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/httpbind
namespace.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 class
Body.Builder
A builder for the body element.static class
Body.Condition
The implementation of the 'condition' attribute of the<body/>
wrapper element, which indicates an error reported by the connection manager.static class
Body.Type
The implementation of the 'type' attribute of the<body/>
element.
-
Field Summary
Fields Modifier and Type Field Description static String
NAMESPACE
http://jabber.org/protocol/httpbindstatic String
XBOSH_NAMESPACE
urn:xmpp:xbosh
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Body.Builder
builder()
Creates a builder for the body element.int
compareTo(Body o)
Compares this body with another body by using the request id.boolean
equals(Object other)
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.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.String
getAuthId()
Gets the 'authid' attribute, which contains the value of the XMPP stream ID generated by the XMPP server.String
getBoshVersion()
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.Condition
getCondition()
Gets a terminal binding condition.String
getContent()
Some clients are constrained to only accept HTTP responses with specific Content-Types (e.g., "text/html").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.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.String
getId()
Gets the session id.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.String
getKey()
Gets the key used to protect insecure connections.Locale
getLanguage()
Gets the language, i.e. the value of the 'xml:lang' attribute.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.String
getNewKey()
Gets the new key used to protect insecure connections.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.Duration
getPolling()
This attribute specifies the shortest allowable polling interval (in seconds).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).Short
getRequests()
This attribute enables the connection manager to limit the number of simultaneous requests the client makes (see Overactivity and Polling Sessions).Long
getRid()
The<body/>
element of every client request MUST possess a sequential request ID encapsulated via the 'rid' attribute.String
getRoute()
A connection manager MAY be configured to enable sessions with more than one server in different domains.String
getSid()
All requests after the first one MUST include a valid 'sid' attribute (provided by the connection manager in the Session Creation Response).String
getStream()
If a connection manager supports the multi-streams feature, it MUST include a 'stream' attribute in its Session Creation Response.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).Jid
getTo()
Gets the 'to' attribute.Body.Type
getType()
The type of the body.URI
getUri()
If the connection manager reports aBody.Condition.SEE_OTHER_URI
error condition, this method returns the URI.String
getVersion()
Gets the XMPP version.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.List<Object>
getWrappedObjects()
Gets an unmodifiable list of wrapped objects.int
hashCode()
boolean
isRestart()
If the client requests a stream restart.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".String
toString()
-
-
-
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_URI
error 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:
getFrom
in 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:
getId
in 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:SessionOpen
Gets the 'to' attribute.- Specified by:
getTo
in 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:LanguageElement
Gets the language, i.e. the value of the 'xml:lang' attribute.- Specified by:
getLanguage
in interfaceLanguageElement
- Returns:
- The language.
-
getVersion
public final String getVersion()
Gets the XMPP version.- Specified by:
getVersion
in 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:
compareTo
in interfaceComparable<Body>
- Parameters:
o
- The body.- Returns:
- The comparison result.
-
-