if (client!=null)
throw new IllegalStateException();
if (_securityPolicy!=null && !_securityPolicy.canHandshake(message))
{
Message reply=newMessage(message);
reply.put(CHANNEL_FIELD,META_HANDSHAKE);
reply.put(SUCCESSFUL_FIELD,Boolean.FALSE);
reply.put(ERROR_FIELD,"403::Handshake denied");
reply=extendSendBayeux(client,reply);
if (reply!=null)
transport.send(reply);
return;
}
client=newRemoteClient();
Message reply=newMessage(message);
reply.put(CHANNEL_FIELD, META_HANDSHAKE);
reply.put(VERSION_FIELD, "1.0");
reply.put(MIN_VERSION_FIELD, "0.9");
if (client!=null)
{
reply.put(SUPP_CONNECTION_TYPE_FIELD, _transports);
reply.put(SUCCESSFUL_FIELD, Boolean.TRUE);
reply.put(CLIENT_FIELD, client.getId());
if (_advice!=null)
reply.put(ADVICE_FIELD,_advice);
}
else
{
reply.put(Bayeux.SUCCESSFUL_FIELD,Boolean.FALSE);
if (_advice!=null)
reply.put(ADVICE_FIELD,_advice);
}
if (isLogDebug())
logDebug("handshake.handle: reply="+reply);
String id=message.getId();
if (id!=null)
reply.put(ID_FIELD,id);
reply=extendSendMeta(client,reply);
if (reply!=null)
transport.send(reply);
}