Skip to content

Commit

Permalink
Copy over all ClientTransport options to new Oort client.
Browse files Browse the repository at this point in the history
Signed-off-by: gregw <gregw@webtide.com>
  • Loading branch information
gregw committed Sep 19, 2023
1 parent 1d2d314 commit 414f069
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
import java.util.stream.Collectors;

import org.cometd.bayeux.Message;
import org.cometd.client.BayeuxClient;
import org.cometd.common.AbstractTransport;
Expand All @@ -37,6 +38,14 @@ public abstract class ClientTransport extends AbstractTransport {
public static final String SCHEDULER_OPTION = "scheduler";
public static final String MAX_SEND_BAYEUX_MESSAGE_SIZE_OPTION = "maxSendBayeuxMessageSize";
public static final String MAX_MESSAGE_SIZE_OPTION = "maxMessageSize";
public static final List<String> KNOWN_OPTIONS = List.of(
URL_OPTION,
MAX_NETWORK_DELAY_OPTION,
JSON_CONTEXT_OPTION,
SCHEDULER_OPTION,
MAX_SEND_BAYEUX_MESSAGE_SIZE_OPTION,
MAX_MESSAGE_SIZE_OPTION
);

private String url;
private ScheduledExecutorService scheduler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;

import org.cometd.bayeux.Channel;
import org.cometd.bayeux.ChannelId;
import org.cometd.bayeux.Message;
Expand Down Expand Up @@ -319,30 +320,25 @@ protected OortComet newOortComet(String cometURL) {
options.put(ClientTransport.JSON_CONTEXT_OPTION, jsonContext);
}

String maxMessageSizeOption = ClientTransport.MAX_MESSAGE_SIZE_OPTION;
Object option = _bayeux.getOption(maxMessageSizeOption);
if (option != null) {
options.put(maxMessageSizeOption, option);
}
for (String clientTransportOption : ClientTransport.KNOWN_OPTIONS) {
Object option = _bayeux.getOption(clientTransportOption);
if (option != null) {
options.put(clientTransportOption, option);
}

maxMessageSizeOption = WebSocketTransport.PREFIX + "." + maxMessageSizeOption;
option = _bayeux.getOption(maxMessageSizeOption);
if (option != null) {
options.put(maxMessageSizeOption, option);
String wsClientTransportOption = WebSocketTransport.PREFIX + "." + clientTransportOption;
option = _bayeux.getOption(wsClientTransportOption);
if (option != null) {
options.put(wsClientTransportOption, option);
}
}

String idleTimeoutOption = WebSocketTransport.PREFIX + "." + WebSocketTransport.IDLE_TIMEOUT_OPTION;
option = _bayeux.getOption(idleTimeoutOption);
Object option = _bayeux.getOption(idleTimeoutOption);
if (option != null) {
options.put(idleTimeoutOption, option);
}

String maxNetworkDelayOption = ClientTransport.MAX_NETWORK_DELAY_OPTION;
option = _bayeux.getOption(maxNetworkDelayOption);
if (option != null) {
options.put(maxNetworkDelayOption, option);
}

List<ClientTransport> transports = new ArrayList<>();
for (ClientTransport.Factory factory : getClientTransportFactories()) {
transports.add(factory.newClientTransport(cometURL, options));
Expand Down

0 comments on commit 414f069

Please sign in to comment.