.command(BusCommands.RemoteSubscribe)
.with(MessageParts.SubjectsList, new HashSet(globalSubscriptions))
.with(MessageParts.PriorityProcessing, "1")
.noErrorHandling().sendNowWith(ServerMessageBusImpl.this, false);
final Message msg = ConversationMessage.create(message)
.toSubject(BuiltInServices.ClientBus.name())
.command(BusCommands.CapabilitiesNotice);
final StringBuilder capabilitiesBuffer = new StringBuilder(25);
final boolean first;
if (ErraiServiceConfigurator.LONG_POLLING) {
capabilitiesBuffer.append(Capabilities.LongPollAvailable.name());
first = false;
}
else {
capabilitiesBuffer.append(Capabilities.NoLongPollAvailable.name());
first = false;
msg.set(MessageParts.PollFrequency, ErraiServiceConfigurator.HOSTED_MODE_TESTING ? 50 : 250);
}
if (webSocketServer || webSocketServlet) {
if (!first) {
capabilitiesBuffer.append(',');
}
capabilitiesBuffer.append(Capabilities.WebSockets.name());
/**
* Advertise where the client can find a websocket.
*/
final String webSocketURL;
final HttpServletRequest request = message.getResource(HttpServletRequest.class, HttpServletRequest.class.getName());
if (webSocketServlet) {
webSocketURL = "ws://" + request.getHeader("Host") + webSocketPath;
}
else {
webSocketURL = "ws://" + request.getServerName() + ":" + webSocketPort + webSocketPath;
}
msg.set(MessageParts.WebSocketURL, webSocketURL);
msg.set(MessageParts.WebSocketToken, WebSocketTokenManager.getNewOneTimeToken(session));
}
msg.set(MessageParts.CapabilitiesFlags, capabilitiesBuffer.toString());
send(msg, false);
createConversation(message)
.toSubject(BuiltInServices.ClientBus.name())