Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ To publish the library to your local Maven repository, you can use the following

Alternatively, to publish only the specific (LiveObjects) module:

./gradlew :live-objects:publishToMavenLocal
./gradlew :liveobjects:publishToMavenLocal


- To use the locally published library in your project, you can add the following dependency in your `build.gradle` file:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Add the following dependency to your `build.gradle` file:

```groovy
dependencies {
runtimeOnly("io.ably:live-objects:1.2.54")
runtimeOnly("io.ably:liveobjects:1.2.54")
}
```

Expand Down
2 changes: 1 addition & 1 deletion android/proguard.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-keep public class io.ably.lib.transport.WebSocketTransport$Factory {*;}
-keep class io.ably.lib.types.** {*;}
-keep class io.ably.lib.objects.*ObjectsPlugin {*;}
-keep class io.ably.lib.objects.*LiveObjectsPlugin {*;}
-keep class io.ably.lib.objects.serialization.*Serializer {*;}
-keep class io.ably.lib.objects.ObjectsJsonSerializer {*;}

Expand Down
6 changes: 3 additions & 3 deletions android/src/main/java/io/ably/lib/realtime/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.ably.lib.types.AblyException;
import io.ably.lib.types.ChannelOptions;
import io.ably.lib.push.PushChannel;
import io.ably.lib.objects.ObjectsPlugin;
import io.ably.lib.objects.LiveObjectsPlugin;


public class Channel extends ChannelBase {
Expand All @@ -14,8 +14,8 @@ public class Channel extends ChannelBase {
*/
public final PushChannel push;

Channel(AblyRealtime ably, String name, ChannelOptions options, ObjectsPlugin objectsPlugin) throws AblyException {
super(ably, name, options, objectsPlugin);
Channel(AblyRealtime ably, String name, ChannelOptions options, LiveObjectsPlugin liveObjectsPlugin) throws AblyException {
super(ably, name, options, liveObjectsPlugin);
this.push = ((io.ably.lib.rest.AblyRest) ably).channels.get(name, options).push;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ dependencies {
implementation(libs.material3)
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.cio)
implementation(project(":liveobjects"))

implementation(project(":live-objects"))
implementation(project(":android"))

implementation(libs.navigation.compose)
Expand Down
6 changes: 3 additions & 3 deletions java/src/main/java/io/ably/lib/realtime/Channel.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package io.ably.lib.realtime;

import io.ably.lib.objects.ObjectsPlugin;
import io.ably.lib.objects.LiveObjectsPlugin;
import io.ably.lib.types.AblyException;
import io.ably.lib.types.ChannelOptions;
import org.jetbrains.annotations.Nullable;

public class Channel extends ChannelBase {
Channel(AblyRealtime ably, String name, ChannelOptions options, @Nullable ObjectsPlugin objectsPlugin) throws AblyException {
super(ably, name, options, objectsPlugin);
Channel(AblyRealtime ably, String name, ChannelOptions options, @Nullable LiveObjectsPlugin liveObjectsPlugin) throws AblyException {
super(ably, name, options, liveObjectsPlugin);
}

public interface MessageListener extends ChannelBase.MessageListener {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import org.jetbrains.annotations.NotNull;

/**
* The ObjectsPlugin interface provides a mechanism for managing and interacting with
* The LiveObjectsPlugin interface provides a mechanism for managing and interacting with
* live data objects in a real-time environment. It allows for the retrieval, disposal, and
* management of Objects instances associated with specific channel names.
*/
public interface ObjectsPlugin {
public interface LiveObjectsPlugin {

/**
* Retrieves an instance of RealtimeObjects associated with the specified channel name.
Expand Down
6 changes: 3 additions & 3 deletions lib/src/main/java/io/ably/lib/objects/ObjectsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public class ObjectsHelper {
private static volatile ObjectsSerializer objectsSerializer;

@Nullable
public static ObjectsPlugin tryInitializeObjectsPlugin(AblyRealtime ablyRealtime) {
public static LiveObjectsPlugin tryInitializeObjectsPlugin(AblyRealtime ablyRealtime) {
try {
Class<?> objectsImplementation = Class.forName("io.ably.lib.objects.DefaultObjectsPlugin");
Class<?> objectsImplementation = Class.forName("io.ably.lib.objects.DefaultLiveObjectsPlugin");
ObjectsAdapter adapter = new Adapter(ablyRealtime);
return (ObjectsPlugin) objectsImplementation
return (LiveObjectsPlugin) objectsImplementation
.getDeclaredConstructor(ObjectsAdapter.class)
.newInstance(adapter);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException |
Expand Down
18 changes: 9 additions & 9 deletions lib/src/main/java/io/ably/lib/realtime/AblyRealtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.Map;

import io.ably.lib.objects.ObjectsHelper;
import io.ably.lib.objects.ObjectsPlugin;
import io.ably.lib.objects.LiveObjectsPlugin;
import io.ably.lib.rest.AblyRest;
import io.ably.lib.rest.Auth;
import io.ably.lib.transport.ConnectionManager;
Expand Down Expand Up @@ -49,7 +49,7 @@ public class AblyRealtime extends AblyRest {
* This field is initialized only if the LiveObjects plugin is present in the classpath.
*/
@Nullable
private final ObjectsPlugin objectsPlugin;
private final LiveObjectsPlugin liveObjectsPlugin;

/**
* Constructs a Realtime client object using an Ably API key or token string.
Expand All @@ -74,9 +74,9 @@ public AblyRealtime(ClientOptions options) throws AblyException {
final InternalChannels channels = new InternalChannels();
this.channels = channels;

objectsPlugin = ObjectsHelper.tryInitializeObjectsPlugin(this);
liveObjectsPlugin = ObjectsHelper.tryInitializeObjectsPlugin(this);

connection = new Connection(this, channels, platformAgentProvider, objectsPlugin);
connection = new Connection(this, channels, platformAgentProvider, liveObjectsPlugin);

if (!StringUtils.isNullOrEmpty(options.recover)) {
RecoveryKeyContext recoveryKeyContext = RecoveryKeyContext.decode(options.recover);
Expand Down Expand Up @@ -122,8 +122,8 @@ public void close() {
}

connection.close();
if (objectsPlugin != null) {
objectsPlugin.dispose();
if (liveObjectsPlugin != null) {
liveObjectsPlugin.dispose();
}
}

Expand Down Expand Up @@ -204,7 +204,7 @@ public Channel get(final String channelName, final ChannelOptions channelOptions
// We're not using computeIfAbsent because that requires Java 1.8.
// Hence there's the slight inefficiency of creating newChannel when it may not be
// needed because there is an existingChannel.
final Channel newChannel = new Channel(AblyRealtime.this, channelName, channelOptions, objectsPlugin);
final Channel newChannel = new Channel(AblyRealtime.this, channelName, channelOptions, liveObjectsPlugin);
final Channel existingChannel = map.putIfAbsent(channelName, newChannel);

if (existingChannel != null) {
Expand All @@ -231,8 +231,8 @@ public void release(String channelName) {
Log.e(TAG, "Unexpected exception detaching channel; channelName = " + channelName, e);
}
}
if (objectsPlugin != null) {
objectsPlugin.dispose(channelName);
if (liveObjectsPlugin != null) {
liveObjectsPlugin.dispose(channelName);
}
}

Expand Down
30 changes: 15 additions & 15 deletions lib/src/main/java/io/ably/lib/realtime/ChannelBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import io.ably.lib.http.HttpCore;
import io.ably.lib.http.HttpUtils;
import io.ably.lib.objects.RealtimeObjects;
import io.ably.lib.objects.ObjectsPlugin;
import io.ably.lib.objects.LiveObjectsPlugin;
import io.ably.lib.rest.RestAnnotations;
import io.ably.lib.transport.ConnectionManager;
import io.ably.lib.transport.ConnectionManager.QueuedMessage;
Expand Down Expand Up @@ -95,16 +95,16 @@ public abstract class ChannelBase extends EventEmitter<ChannelEvent, ChannelStat
*/
private boolean released = false;

@Nullable private final ObjectsPlugin objectsPlugin;
@Nullable private final LiveObjectsPlugin liveObjectsPlugin;

public RealtimeObjects getObjects() throws AblyException {
if (objectsPlugin == null) {
if (liveObjectsPlugin == null) {
throw AblyException.fromErrorInfo(
new ErrorInfo("LiveObjects plugin hasn't been installed, " +
"add runtimeOnly('io.ably:live-objects:<ably-version>') to your dependency tree", 400, 40019)
"add runtimeOnly('io.ably:liveobjects:<ably-version>') to your dependency tree", 400, 40019)
);
}
return objectsPlugin.getInstance(name);
return liveObjectsPlugin.getInstance(name);
}

public final RealtimeAnnotations annotations;
Expand Down Expand Up @@ -147,11 +147,11 @@ private void setState(ChannelState newState, ErrorInfo reason, boolean resumed,
}

// cover states other than attached, ChannelState.attached already covered in setAttached
if (objectsPlugin != null && newState!= ChannelState.attached) {
if (liveObjectsPlugin != null && newState!= ChannelState.attached) {
try {
objectsPlugin.handleStateChange(name, newState, false);
liveObjectsPlugin.handleStateChange(name, newState, false);
} catch (Throwable t) {
Log.e(TAG, "Unexpected exception in objectsPlugin.handle", t);
Log.e(TAG, "Unexpected exception in liveObjectsPlugin.handle", t);
}
}

Expand Down Expand Up @@ -449,11 +449,11 @@ private void setAttached(ProtocolMessage message) {
}
return;
}
if (objectsPlugin != null) {
if (liveObjectsPlugin != null) {
try {
objectsPlugin.handleStateChange(name, ChannelState.attached, message.hasFlag(Flag.has_objects));
liveObjectsPlugin.handleStateChange(name, ChannelState.attached, message.hasFlag(Flag.has_objects));
} catch (Throwable t) {
Log.e(TAG, "Unexpected exception in objectsPlugin.handle", t);
Log.e(TAG, "Unexpected exception in liveObjectsPlugin.handle", t);
}
}
if(state == ChannelState.attached) {
Expand Down Expand Up @@ -1326,7 +1326,7 @@ else if(stateChange.current.equals(failureState)) {
}
}

ChannelBase(AblyRealtime ably, String name, ChannelOptions options, @Nullable ObjectsPlugin objectsPlugin) throws AblyException {
ChannelBase(AblyRealtime ably, String name, ChannelOptions options, @Nullable LiveObjectsPlugin liveObjectsPlugin) throws AblyException {
Log.v(TAG, "RealtimeChannel(); channel = " + name);
this.ably = ably;
this.name = name;
Expand All @@ -1336,9 +1336,9 @@ else if(stateChange.current.equals(failureState)) {
this.attachResume = false;
state = ChannelState.initialized;
this.decodingContext = new DecodingContext();
this.objectsPlugin = objectsPlugin;
if (objectsPlugin != null) {
objectsPlugin.getInstance(name); // Make objects instance ready to process sync messages
this.liveObjectsPlugin = liveObjectsPlugin;
if (liveObjectsPlugin != null) {
liveObjectsPlugin.getInstance(name); // Make objects instance ready to process sync messages
}
this.annotations = new RealtimeAnnotations(
this,
Expand Down
6 changes: 3 additions & 3 deletions lib/src/main/java/io/ably/lib/realtime/Connection.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.ably.lib.realtime;

import io.ably.lib.objects.ObjectsPlugin;
import io.ably.lib.objects.LiveObjectsPlugin;
import io.ably.lib.realtime.ConnectionStateListener.ConnectionStateChange;
import io.ably.lib.transport.ConnectionManager;
import io.ably.lib.types.AblyException;
Expand Down Expand Up @@ -123,10 +123,10 @@ public void close() {
* internal
*****************/

Connection(AblyRealtime ably, ConnectionManager.Channels channels, PlatformAgentProvider platformAgentProvider, ObjectsPlugin objectsPlugin) throws AblyException {
Connection(AblyRealtime ably, ConnectionManager.Channels channels, PlatformAgentProvider platformAgentProvider, LiveObjectsPlugin liveObjectsPlugin) throws AblyException {
this.ably = ably;
this.state = ConnectionState.initialized;
this.connectionManager = new ConnectionManager(ably, this, channels, platformAgentProvider, objectsPlugin);
this.connectionManager = new ConnectionManager(ably, this, channels, platformAgentProvider, liveObjectsPlugin);
}

public void onConnectionStateChange(ConnectionStateChange stateChange) {
Expand Down
12 changes: 6 additions & 6 deletions lib/src/main/java/io/ably/lib/transport/ConnectionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import io.ably.lib.debug.DebugOptions;
import io.ably.lib.debug.DebugOptions.RawProtocolListener;
import io.ably.lib.http.HttpHelpers;
import io.ably.lib.objects.ObjectsPlugin;
import io.ably.lib.objects.LiveObjectsPlugin;
import io.ably.lib.realtime.AblyRealtime;
import io.ably.lib.realtime.Channel;
import io.ably.lib.realtime.ChannelState;
Expand Down Expand Up @@ -99,7 +99,7 @@ public class ConnectionManager implements ConnectListener {
* <p>
* This field is initialized only if the LiveObjects plugin is present in the classpath.
*/
private final ObjectsPlugin objectsPlugin;
private final LiveObjectsPlugin liveObjectsPlugin;

/**
* Methods on the channels map owned by the {@link AblyRealtime} instance
Expand Down Expand Up @@ -773,12 +773,12 @@ public void run() {
* ConnectionManager
***********************/

public ConnectionManager(final AblyRealtime ably, final Connection connection, final Channels channels, final PlatformAgentProvider platformAgentProvider, ObjectsPlugin objectsPlugin) throws AblyException {
public ConnectionManager(final AblyRealtime ably, final Connection connection, final Channels channels, final PlatformAgentProvider platformAgentProvider, LiveObjectsPlugin liveObjectsPlugin) throws AblyException {
this.ably = ably;
this.connection = connection;
this.channels = channels;
this.platformAgentProvider = platformAgentProvider;
this.objectsPlugin = objectsPlugin;
this.liveObjectsPlugin = liveObjectsPlugin;

ClientOptions options = ably.options;
this.hosts = new Hosts(options.realtimeHost, Defaults.HOST_REALTIME, options);
Expand Down Expand Up @@ -1239,9 +1239,9 @@ public void onMessage(ITransport transport, ProtocolMessage message) throws Ably
break;
case object:
case object_sync:
if (objectsPlugin != null) {
if (liveObjectsPlugin != null) {
try {
objectsPlugin.handle(message);
liveObjectsPlugin.handle(message);
} catch (Throwable t) {
Log.e(TAG, "objectsPlugin threw while handling message", t);
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
POM_ARTIFACT_ID=live-objects
POM_ARTIFACT_ID=liveobjects
POM_NAME=Live Objects plugin for Ably Pub/Sub SDK
POM_DESCRIPTION=Live Objects plugin for Ably Pub/Sub SDK
POM_PACKAGING=jar
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import io.ably.lib.realtime.ChannelState
import io.ably.lib.types.ProtocolMessage
import java.util.concurrent.ConcurrentHashMap

public class DefaultObjectsPlugin(private val adapter: ObjectsAdapter) : ObjectsPlugin {
public class DefaultLiveObjectsPlugin(private val adapter: ObjectsAdapter) : LiveObjectsPlugin {

private val objects = ConcurrentHashMap<String, DefaultRealtimeObjects>()

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ include("network-client-core")
include("network-client-default")
include("network-client-okhttp")
include("pubsub-adapter")
include("live-objects")
include("liveobjects")
include("examples")
Loading