|
14 | 14 | import io.ably.lib.debug.DebugOptions; |
15 | 15 | import io.ably.lib.debug.DebugOptions.RawProtocolListener; |
16 | 16 | import io.ably.lib.http.HttpHelpers; |
| 17 | +import io.ably.lib.objects.LiveObjectsPlugin; |
| 18 | +import io.ably.lib.plugins.PluginConnectionAdapter; |
17 | 19 | import io.ably.lib.realtime.AblyRealtime; |
18 | 20 | import io.ably.lib.realtime.Channel; |
19 | 21 | import io.ably.lib.realtime.CompletionListener; |
|
35 | 37 | import io.ably.lib.util.PlatformAgentProvider; |
36 | 38 | import io.ably.lib.util.ReconnectionStrategy; |
37 | 39 |
|
38 | | -public class ConnectionManager implements ConnectListener { |
| 40 | +public class ConnectionManager implements ConnectListener, PluginConnectionAdapter { |
39 | 41 | final ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); |
40 | 42 |
|
41 | 43 | /************************************************************** |
@@ -79,6 +81,13 @@ public class ConnectionManager implements ConnectListener { |
79 | 81 | */ |
80 | 82 | private boolean cleaningUpAfterEnteringTerminalState = false; |
81 | 83 |
|
| 84 | + /** |
| 85 | + * A nullable reference to the LiveObjects plugin. |
| 86 | + * <p> |
| 87 | + * This field is initialized only if the LiveObjects plugin is present in the classpath. |
| 88 | + */ |
| 89 | + private final LiveObjectsPlugin liveObjectsPlugin; |
| 90 | + |
82 | 91 | /** |
83 | 92 | * Methods on the channels map owned by the {@link AblyRealtime} instance |
84 | 93 | * which the {@link ConnectionManager} needs access to. |
@@ -764,11 +773,12 @@ public void run() { |
764 | 773 | * ConnectionManager |
765 | 774 | ***********************/ |
766 | 775 |
|
767 | | - public ConnectionManager(final AblyRealtime ably, final Connection connection, final Channels channels, final PlatformAgentProvider platformAgentProvider) throws AblyException { |
| 776 | + public ConnectionManager(final AblyRealtime ably, final Connection connection, final Channels channels, final PlatformAgentProvider platformAgentProvider, LiveObjectsPlugin liveObjectsPlugin) throws AblyException { |
768 | 777 | this.ably = ably; |
769 | 778 | this.connection = connection; |
770 | 779 | this.channels = channels; |
771 | 780 | this.platformAgentProvider = platformAgentProvider; |
| 781 | + this.liveObjectsPlugin = liveObjectsPlugin; |
772 | 782 |
|
773 | 783 | ClientOptions options = ably.options; |
774 | 784 | this.hosts = new Hosts(options.realtimeHost, Defaults.HOST_REALTIME, options); |
@@ -1220,6 +1230,12 @@ public void onMessage(ITransport transport, ProtocolMessage message) throws Ably |
1220 | 1230 | case auth: |
1221 | 1231 | addAction(new ReauthAction()); |
1222 | 1232 | break; |
| 1233 | + case object: |
| 1234 | + case object_sync: |
| 1235 | + if (liveObjectsPlugin != null) { |
| 1236 | + liveObjectsPlugin.handle(message); |
| 1237 | + } |
| 1238 | + break; |
1223 | 1239 | default: |
1224 | 1240 | onChannelMessage(message); |
1225 | 1241 | } |
@@ -1667,6 +1683,11 @@ public QueuedMessage(ProtocolMessage msg, CompletionListener listener) { |
1667 | 1683 | } |
1668 | 1684 | } |
1669 | 1685 |
|
| 1686 | + @Override |
| 1687 | + public void send(ProtocolMessage msg, CompletionListener listener) throws AblyException { |
| 1688 | + this.send(msg, true, listener); |
| 1689 | + } |
| 1690 | + |
1670 | 1691 | public void send(ProtocolMessage msg, boolean queueEvents, CompletionListener listener) throws AblyException { |
1671 | 1692 | State state; |
1672 | 1693 | synchronized(this) { |
|
0 commit comments