}
try {
//------------------ Login -------------------------------------------------
if (actionType.equals("login") || actionType.equals("connect")) {
ConnectQos connectQos;
if (actionType.equals("connect")) {
String qos = Util.getParameter(req, "xmlBlaster.connectQos", null);
if (qos == null || qos.length() < 1)
throw new XmlBlasterException(glob, ErrorCode.USER_CONFIGURATION, ME, "Missing connect QoS. Pass xmlBlaster.connectQos='<qos> ... </qos>' with your URL in your POST in a hidden form field or in your cookie.");
connectQos = new ConnectQos(glob, glob.getConnectQosFactory().readObject(qos));
}
else {
String loginName = Util.getParameter(req, "xmlBlaster.loginName", null); // "Joe";
if (loginName == null || loginName.length() < 1)
throw new XmlBlasterException(glob, ErrorCode.USER_CONFIGURATION, ME, "Missing login name. Pass xmlBlaster.loginName=xy with your URL or in your cookie.");
String passwd = Util.getParameter(req, "xmlBlaster.passwd", null); // "secret";
if (passwd == null || passwd.length() < 1)
throw new XmlBlasterException(glob, ErrorCode.USER_CONFIGURATION, ME, "Missing passwd");
connectQos = new ConnectQos(glob, loginName, passwd);
}
ME = "BlasterHttpProxyServlet-" + req.getRemoteAddr() + "-" +
connectQos.getSessionName().getLoginName() + "-" + sessionId;
I_XmlBlasterAccess xmlBlasterAccess = glob.getXmlBlasterAccess();
HttpPushHandler pushHandler = new HttpPushHandler(req, res, sessionId,
connectQos.getSessionName().getRelativeName(),
xmlBlasterAccess);
xmlBlasterAccess.connect(connectQos, pushHandler);
if (!session.isNew()) {
pushHandler.startPing();
}
else {
log.info("Login action, browser has not yet joined this sessionId (cookie), so first pings pong may return an invalid sessionId");
pushHandler.startPing(); // This is too early here, we need to start the ping thread later?
}
BlasterHttpProxy.addHttpPushHandler( sessionId, pushHandler );
// Don't fall out of doGet() to keep the HTTP connection open
log.info("Waiting forever, permanent HTTP connection from " +
req.getRemoteHost() + "/" + req.getRemoteAddr() +
", sessionName=" + connectQos.getSessionName().getRelativeName() + " sessionId=" + sessionId +
"', protocol='" + req.getProtocol() +
"', agent='" + req.getHeader("User-Agent") +
"', referer='" + req.getHeader("Referer") +
"'.");