-
Notifications
You must be signed in to change notification settings - Fork 42
[ECO-5375] Define internal liveobject data models #1087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
29d7854
[ECO-5375] Refactored LiveObjects plugin to handle channelSerial
sacOO7 375328e
[ECO-5375] Created ObjectMessage.kt, declared data classes as per spec
sacOO7 431cfe7
[ECO-5375] Updated code as per review comments
sacOO7 4dfb1a0
[ECO-5375] Updated liveObjectsAdapter sendAsync method to use suspend…
sacOO7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package io.ably.lib.objects; | ||
|
|
||
| import io.ably.lib.realtime.AblyRealtime; | ||
| import io.ably.lib.realtime.CompletionListener; | ||
| import io.ably.lib.types.AblyException; | ||
| import io.ably.lib.types.ProtocolMessage; | ||
| import io.ably.lib.util.Log; | ||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| public class Adapter implements LiveObjectsAdapter { | ||
| private final AblyRealtime ably; | ||
| private static final String TAG = LiveObjectsAdapter.class.getName(); | ||
|
|
||
| public Adapter(@NotNull AblyRealtime ably) { | ||
| this.ably = ably; | ||
| } | ||
|
|
||
| @Override | ||
| public void setChannelSerial(@NotNull String channelName, @NotNull String channelSerial) { | ||
| if (ably.channels.containsKey(channelName)) { | ||
| ably.channels.get(channelName).properties.channelSerial = channelSerial; | ||
| } else { | ||
| Log.e(TAG, "setChannelSerial(): channel not found: " + channelName); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void send(ProtocolMessage msg, CompletionListener listener) throws AblyException { | ||
| // Always queue LiveObjects messages to ensure reliable state synchronization and proper acknowledgment | ||
| ably.connection.connectionManager.send(msg, true, listener); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 5 additions & 22 deletions
27
live-objects/src/main/kotlin/io/ably/lib/objects/DefaultLiveObjectsPlugin.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
live-objects/src/main/kotlin/io/ably/lib/objects/Helpers.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package io.ably.lib.objects | ||
|
|
||
| import io.ably.lib.realtime.CompletionListener | ||
| import io.ably.lib.types.AblyException | ||
| import io.ably.lib.types.ErrorInfo | ||
| import io.ably.lib.types.ProtocolMessage | ||
| import kotlinx.coroutines.suspendCancellableCoroutine | ||
| import kotlin.coroutines.resume | ||
| import kotlin.coroutines.resumeWithException | ||
|
|
||
| internal suspend fun LiveObjectsAdapter.sendAsync(message: ProtocolMessage) = suspendCancellableCoroutine { continuation -> | ||
| try { | ||
| this.send(message, object : CompletionListener { | ||
| override fun onSuccess() { | ||
| continuation.resume(Unit) | ||
| } | ||
|
|
||
| override fun onError(reason: ErrorInfo) { | ||
| continuation.resumeWithException(AblyException.fromErrorInfo(reason)) | ||
| } | ||
| }) | ||
| } catch (e: Exception) { | ||
| continuation.resumeWithException(e) | ||
| } | ||
| } | ||
|
|
||
| internal enum class ProtocolMessageFormat(private val value: String) { | ||
| Msgpack("msgpack"), | ||
| Json("json"); | ||
|
|
||
| override fun toString(): String = value | ||
| } | ||
|
|
||
| internal class Binary(val data: ByteArray?) { | ||
| override fun equals(other: Any?): Boolean { | ||
| if (this === other) return true | ||
| if (other !is Binary) return false | ||
| return data?.contentEquals(other.data) == true | ||
| } | ||
|
|
||
| override fun hashCode(): Int { | ||
| return data?.contentHashCode() ?: 0 | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.