Commit 991ed7ae authored by huni's avatar huni

Added support for acknowledgements.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/branches@10604 b35dd754-fafc-0310-a699-88a17e54d16e
parent bde9a920
...@@ -230,7 +230,7 @@ public class HttpSession extends LocalClientSession { ...@@ -230,7 +230,7 @@ public class HttpSession extends LocalClientSession {
* *
* @param language the language this session is using. * @param language the language this session is using.
*/ */
public void setLanaguage(String language) { public void setLanguage(String language) {
this.language = language; this.language = language;
} }
...@@ -320,7 +320,11 @@ public class HttpSession extends LocalClientSession { ...@@ -320,7 +320,11 @@ public class HttpSession extends LocalClientSession {
} }
/** /**
* Returns true if this session is a polling session, i.e. wait or hold attribute is set to 0. * Returns true if this session is a polling session. Some clients may be restricted to open
* only one connection to the server. In this case the client SHOULD inform the server by
* setting the values of the 'wait' and/or 'hold' attributes in its session creation request
* to "0", and then "poll" the server at regular intervals throughout the session for stanzas
* it may have received from the server.
* *
* @return true if this session is a polling session. * @return true if this session is a polling session.
*/ */
...@@ -395,8 +399,26 @@ public class HttpSession extends LocalClientSession { ...@@ -395,8 +399,26 @@ public class HttpSession extends LocalClientSession {
} }
/** /**
* Sets the major version of BOSH which the client implements. Currently, the only versions supported * Returns the time in milliseconds since the epoch that this session was last active. Activity
* by Openfire are 1.5 and 1.6. * is a request was either made or responded to. If the session is currently active, meaning
* there are connections awaiting a response, the current time is returned.
*
* @return the time in milliseconds since the epoch that this session was last active.
*/
public long getLastAcknowledged() {
long ack = lastRequestID;
Collections.sort(connectionQueue, connectionComparator);
for (HttpConnection connection : connectionQueue) {
if (connection.getRequestId() == ack + 1) {
ack++;
}
}
return ack;
}
/**
* Sets the major version of BOSH which the client implements. Currently, the only versions
* supported by Openfire are 1.5 and 1.6.
* *
* @param version the major version of BOSH which the client implements. * @param version the major version of BOSH which the client implements.
*/ */
...@@ -426,9 +448,9 @@ public class HttpSession extends LocalClientSession { ...@@ -426,9 +448,9 @@ public class HttpSession extends LocalClientSession {
} }
/** /**
* Sets the minor version of BOSH which the client implements. Currently, the only versions supported * Sets the minor version of BOSH which the client implements. Currently, the only versions
* by Openfire are 1.5 and 1.6. Any versions less than or equal to 5 will be interpreted as * supported by Openfire are 1.5 and 1.6. Any versions less than or equal to 5 will be
* 5 and any values greater than or equal to 6 will be interpreted as 6. * interpreted as 5 and any values greater than or equal to 6 will be interpreted as 6.
* *
* @param version the minor version of BOSH which the client implements. * @param version the minor version of BOSH which the client implements.
*/ */
...@@ -751,7 +773,13 @@ public class HttpSession extends LocalClientSession { ...@@ -751,7 +773,13 @@ public class HttpSession extends LocalClientSession {
private String createDeliverable(Collection<Deliverable> elements) { private String createDeliverable(Collection<Deliverable> elements) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("<body xmlns='" + "http://jabber.org/protocol/httpbind" + "'>"); builder.append("<body xmlns='" + "http://jabber.org/protocol/httpbind" + "'");
long ack = getLastAcknowledged();
if(ack > lastRequestID)
builder.append(" ack='" + ack + "'");
builder.append(">");
for (Deliverable child : elements) { for (Deliverable child : elements) {
builder.append(child.getDeliverable()); builder.append(child.getDeliverable());
} }
...@@ -816,9 +844,12 @@ public class HttpSession extends LocalClientSession { ...@@ -816,9 +844,12 @@ public class HttpSession extends LocalClientSession {
} }
private static String createEmptyBody() { private String createEmptyBody() {
Element body = DocumentHelper.createElement("body"); Element body = DocumentHelper.createElement("body");
body.addNamespace("", "http://jabber.org/protocol/httpbind"); body.addNamespace("", "http://jabber.org/protocol/httpbind");
long ack = getLastAcknowledged();
if(ack > lastRequestID)
body.addAttribute("ack", String.valueOf(ack));
return body.asXML(); return body.asXML();
} }
......
...@@ -141,7 +141,7 @@ public class HttpSessionManager { ...@@ -141,7 +141,7 @@ public class HttpSessionManager {
} }
// Store language and version information in the connection. // Store language and version information in the connection.
session.setLanaguage(language); session.setLanguage(language);
String [] versionString = version.split("\\."); String [] versionString = version.split("\\.");
session.setMajorVersion(Integer.parseInt(versionString[0])); session.setMajorVersion(Integer.parseInt(versionString[0]));
...@@ -323,6 +323,7 @@ public class HttpSessionManager { ...@@ -323,6 +323,7 @@ public class HttpSessionManager {
if ((session.getMajorVersion() == 1 && session.getMinorVersion() >= 6) || if ((session.getMajorVersion() == 1 && session.getMinorVersion() >= 6) ||
session.getMajorVersion() > 1) { session.getMajorVersion() > 1) {
response.addAttribute("hold", String.valueOf(session.getHold())); response.addAttribute("hold", String.valueOf(session.getHold()));
response.addAttribute("ack", String.valueOf(session.getLastAcknowledged()));
response.addAttribute("ver", String.valueOf(session.getMajorVersion()) response.addAttribute("ver", String.valueOf(session.getMajorVersion())
+ "." + String.valueOf(session.getMinorVersion())); + "." + String.valueOf(session.getMinorVersion()));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment