Skip to content
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

Realtime Channel attach, detach and state events #20

Merged
merged 31 commits into from
Aug 12, 2020

Conversation

tiholic
Copy link
Contributor

@tiholic tiholic commented Jul 22, 2020

Realtime Channel API enhancement

  1. Implementation for Realtime's ChannelStateChange event listener
  2. attach and detach implemented on a RealtimeChannel
  3. setOptions method is updated to throw an exception, as ChannelOptions are not supported in current PR

Other (non-API) enhancements

  1. Ability to pass payload via EventChannel for listening to platform events. That payload can be passed as an AblyEventMessage. This is similar to AblyMessage except that it carries an eventName attributes instead of a handleId
  2. implement new platform methods attachRealtimeChannel, detachRealtimeChannel, setRealtimeChannelOptions

@QuintinWillison QuintinWillison changed the base branch from master to main July 23, 2020 07:53
Copy link
Contributor

@QuintinWillison QuintinWillison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done a first sweep - there's sure to be stuff I've overlooked but I think there's enough feedback here to keep you busy with some improvements that'll make the code easier to read. Please, please, please default to using final / const wherever possible - in particular final for Java object references and const for Objective-C object pointers. They make your intent clear, in particular within the busier methods and functions where local variable intent, purpose and mutability is not always clear.

tiholic added a commit that referenced this pull request Jul 30, 2020
tiholic added 23 commits August 3, 2020 16:03
ConnectionStateChange.current is set as RealtimeConnection~state as soon
as event is received before giving it back to source listeners.
1. Channel can be created by passing just the name
 or both name and channel options
2. As de-registering just requires getting hold of a channel name,
 options is not used in onCancel method on platform side
3. Example updated with API

Support:
Android ✓
iOS ✓
…ptions

1. `attachRealtimeChannel` - to attach to a channel
2. `detachRealtimeChannel` - to detach from a channel
3. `setRealtimeChannelOptions` - to update channel options
1. Returning proper message for errors reg. "onRealtimeChannelStateChanged"
2. ChannelStateChange errorInfo decoding handled properly
1. attach and detach use completion listeners/callbacks
2. setOptions is supported only on android side
as cocoa doesn't have that API yet (may be 🤔)

Android RealtimeChannelStateChange listener implemented

Support:
Android ✓
iOS ✓
Enable "close connection", "Attach to channel" and  "Detach from channel"
Dispose listeners on widget dispose.
 Remove unwanted comments, delays
 Added necessary comments and print logs in example
Channel options support is completely removed from dart side,
 but the methods are retained on Android/iOS side as to support at later
 point in time.
 Create an inline listener and update the connection and channel state
 property respectively
@tiholic tiholic force-pushed the feature/channel-state-events branch from bb9f4f5 to f7bf23f Compare August 3, 2020 10:34
@tiholic tiholic requested a review from zoechi August 3, 2020 11:27
Copy link
Contributor

@zoechi zoechi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few suggestions

lib/src/impl/realtime/channels.dart Show resolved Hide resolved
example/lib/main.dart Outdated Show resolved Hide resolved
example/lib/main.dart Show resolved Hide resolved
lib/src/impl/message.dart Show resolved Hide resolved
lib/src/impl/platform_object.dart Outdated Show resolved Hide resolved
lib/src/impl/realtime/channels.dart Outdated Show resolved Hide resolved
lib/src/impl/realtime/channels.dart Show resolved Hide resolved
This was referenced Aug 4, 2020
@tiholic tiholic merged commit f5c67ff into main Aug 12, 2020
tiholic added a commit that referenced this pull request Aug 12, 2020
tiholic added a commit that referenced this pull request Aug 12, 2020
tiholic added a commit that referenced this pull request Aug 12, 2020
@tiholic tiholic deleted the feature/channel-state-events branch August 12, 2020 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants