session.write0(getSessionCreationResponse(session));
}
private Stanza getSessionCreationResponse(BoshBackedSessionContext session) {
StanzaBuilder body = new StanzaBuilder("body", NamespaceURIs.XEP0124_BOSH);
body.addAttribute("wait", Integer.toString(session.getWait()));
body.addAttribute("inactivity", Integer.toString(session.getInactivity()));
body.addAttribute("polling", Integer.toString(session.getPolling()));
body.addAttribute("requests", Integer.toString(session.getRequests()));
body.addAttribute("hold", Integer.toString(session.getHold()));
body.addAttribute("sid", session.getSessionId());
body.addAttribute("ver", session.getBoshVersion());
body.addAttribute("from", session.getServerJID().getFullQualifiedName());
body.addAttribute("secure", "true");
body.addAttribute("maxpause", Integer.toString(session.getMaxPause()));
// adding the ack attribute here is needed because when responding to o request with the same RID (as is the case here)
// the ack would not be included on BoshBackedSessionContext#write0, but this first ack is required.
body.addAttribute("ack", Long.toString(session.getHighestReadRid()));
Stanza features = new ServerResponses().getFeaturesForAuthentication(serverRuntimeContext.getServerFeatures()
.getAuthenticationMethods());
body.addPreparedElement(features);
return body.build();
}