Commit 4a84e041 authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

Added session termination

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/branches@5865 b35dd754-fafc-0310-a699-88a17e54d16e
parent 08e4d7c8
......@@ -19,6 +19,7 @@ import org.dom4j.io.XMPPPacketReader;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.DocumentHelper;
import org.mortbay.util.ajax.ContinuationSupport;
import javax.servlet.http.HttpServlet;
......@@ -132,11 +133,20 @@ public class HttpBindServlet extends HttpServlet {
Log.error("Error sending packet to client.", nc);
return;
}
connection.setContinuation(ContinuationSupport.getContinuation(request, connection));
String type = rootNode.attributeValue("type");
if ("terminate".equals(type)) {
session.close();
respond(response, createEmptyBody().getBytes("utf-8"));
}
else {
connection
.setContinuation(ContinuationSupport.getContinuation(request, connection));
request.setAttribute("request-connection", connection);
respond(response, connection);
}
}
}
private void createNewSession(HttpServletRequest request, HttpServletResponse response,
Element rootNode)
......@@ -176,6 +186,10 @@ public class HttpBindServlet extends HttpServlet {
content = createEmptyBody().getBytes("utf-8");
}
respond(response, content);
}
private void respond(HttpServletResponse response, byte [] content) throws IOException {
response.setStatus(HttpServletResponse.SC_OK);
response.setContentType("text/xml");
response.setCharacterEncoding("utf-8");
......@@ -185,7 +199,9 @@ public class HttpBindServlet extends HttpServlet {
}
private String createEmptyBody() {
return "<body xmlns='http://jabber.org/protocol/httpbind'/>";
Element body = DocumentHelper.createElement("body");
body.addNamespace("", "http://jabber.org/protocol/httpbind");
return body.asXML();
}
private long getLongAttribue(String value, long defaultValue) {
......
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