ClientImpl client = clientId!=null?(ClientImpl)getTomcatBayeux().getClient(clientId):
(ClientImpl)event.getHttpServletRequest().getAttribute("client");
boolean success = false;
HttpError error = validate();
if (error == null) {
ChannelImpl chimpl = (ChannelImpl)getTomcatBayeux().getChannel(channel,false);
MessageImpl mimpl = (MessageImpl)getTomcatBayeux().newMessage(client);
try {
String[] keys = JSONObject.getNames(msgData);
for (int i = 0; i < keys.length; i++) {
mimpl.put(keys[i], msgData.get(keys[i]));
}
success = true;
((HashMap) response.get(Bayeux.ADVICE_FIELD)).put(Bayeux.RECONNECT_FIELD, Bayeux.RETRY_RESPONSE);
((HashMap) response.get(Bayeux.ADVICE_FIELD)).put(Bayeux.INTERVAL_FIELD, getReconnectInterval());
}catch (JSONException x) {
if (log.isErrorEnabled()) log.error("Unable to parse:"+msgData,x);
throw new BayeuxException(x);
}
chimpl.publish(mimpl);
}
if(!success) {
response.put(Bayeux.SUCCESSFUL_FIELD,Boolean.FALSE);
response.put(Bayeux.ERROR_FIELD, error.toString());
((HashMap) response.get(Bayeux.ADVICE_FIELD)).put(Bayeux.RECONNECT_FIELD, Bayeux.HANDSHAKE_RESPONSE);