Binding a user session is done by sending a request using HTTP POST method for /rest/adhoc/bosh@domain.com with the following content:
Request requires authentication using Basic HTTP Authentication
<command>
<node>pre-bind-bosh-session</node>
<fields>
<item>
<var>from</var>
<value>user_jid@domain/resource</value>
</item>
<item>
<var>hold</var>
<value>1</value>
</item>
<item>
<var>wait</var>
<value>60</value>
</item>
</fields>
</command>The Following parameters can be adjusted:
<value/> node of the item identified by the from variable; this can be either a FullJID or a BareJID. In the latter case, a random resource will be generated for the session being bound.<value/> node of the item identified by hold variable. This value matches the hold attribute specified in XEP-0124: Session Creation Response<value/> node of the item identified by wait variable. This value matches the wait attribute specified in XEP-0124: Session Creation ResponseAs a response one will receive and XML with the result containing additionally available session and RID that can be used in the client to attach to the session, e.g.:
<command>
<jid>bosh@vhost</jid>
<node>pre-bind-bosh-session</node>
<fields>
<item>
<var>from</var>
<label>jid-single</label>
<value>user_jid@domain/resource</value>
</item>
<item>
<var>hostname</var>
<label>jid-single</label>
<value>node_hostname</value>
</item>
<item>
<var>rid</var>
<label>text-single</label>
<value>9929332</value>
</item>
<item>
<var>sid</var>
<label>text-single</label>
<value>3f1b6e70-8528-44bb-8f23-77e7c4a8cf1a</value>
</item>
<item>
<var>hold</var>
<label>text-single</label>
<value>1</value>
</item>
<item>
<var>wait</var>
<label>text-single</label>
<value>60</value>
</item>
</fields>
</command>For example, having the above XML request stored in prebind file, one can execute the request using $curl:
>curl -X POST -d @prebind http://admin%40domain:pass@domain:8080/rest/adhoc/bosh@domain --header "Content-Type:text/xml"
To execute the command to pre-bind BOSH session in JSON format, make a request using POST method to /rest/adhoc/bosh@domain.com sending the following content:
{
"command" : {
"node" : "pre-bind-bosh-session"",
"fields" : [
{
"var" : "from",
"value" : "user_jid@domain/resource"
},
{
"var" : "hold",
"value" : "1"
},
{
"var" : "wait",
"value" : "60"
}
]
}
}This example replicates the same request presented above in XML format.