Skip to content

Commit

Permalink
feat: optionally return ChannelStateChange from attach methods
Browse files Browse the repository at this point in the history
  • Loading branch information
owenpearson committed Jun 29, 2023
1 parent 670230e commit 3a9499f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions textile/features.textile
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,8 @@ h3(#realtime-channel). RealtimeChannel
*** @(RTL4c1)@ The @ATTACH@ ProtocolMessage @channelSerial@ field must be set to the @channelSerial@ of the most recent message/presence ProtocolMessage received on that channel (which will have been stored in the channel per @RTL15b@). If no messages have been received on the channel, the field may be set to @null@ or omitted.
** @(RTL4f)@ Once an @ATTACH@ @ProtocolMessage@ is sent, if an @ATTACHED@ @ProtocolMessage@ is not received within the "default realtime request timeout":#defaults, the attach request should be treated as though it has failed and the channel should transition to the @SUSPENDED@ state. The channel will then be subsequently automatically re-attached as described in "RTL13":#RTL13
** @(RTL4d)@ A callback (or other language-idiomatic equivalent) can be provided that is called when the channel next moves to one of @ATTACHED@, @DETACHED@, @SUSPENDED@, or @FAILED@ states. In the case of @ATTACHED@ the callback is called with no argument. In all other cases it is called with an @ErrorInfo@ corresponding to the @ChannelStateChange.reason@ of the state change (or a fallback if there is no @reason@) to indicate that the attach has failed. (Note: when combined with RTL4f, this means that if the connection is @CONNECTED@, the callback is guaranteed to be called within @realtimeRequestTimeout@ of the @attach()@ call)
*** @(RTL4d1)@ Optionally, upon success, the callback may be invoked with the @ChannelStateChange@ object once the channel is attached. If the channel is already attached, it should be invoked with @null@.
** @(RTL4n)@ Optionally, upon success, may return the @ChannelStateChange@ object once the channel is attached. If the channel is already attached, it should return @null@.
** @(RTL4e)@ If the user does not have sufficient permissions to attach to the channel, the channel will transition to @FAILED@ and set the @RealtimeChannel#errorReason@
** @(RTL4j)@ If the attach is not a clean attach (defined in @RTL4j1@), for example an automatic reattach triggered by "@RTN15c3@":#RTN15c3 or "@RTL13a@":#RTL13a (non-exhaustive), the library should set the "@ATTACH_RESUME@":#TR3f flag in the @ATTACH@ message
*** @(RTL4j1)@ A 'clean attach' is an attach attempt where the channel has either not previously been attached or has been explicitly detached since the last time it was attached. Note that this is not purely a function of the immediate previous channel state. An example implementation would be to set the flag from an @attachResume@ private boolean variable on the channel, that starts out set to @false@, is set to @true@ when the channel moves to the @ATTACHED@ state, and set to @false@ when the channel moves to the @DETACHING@ or @FAILED@ states.
Expand Down Expand Up @@ -1925,7 +1927,7 @@ class RealtimeChannel: // RTL*
push: PushChannel // RSH7
modes: readonly [ChannelMode] // RTL4m
params: readonly Dict<String, String> // RTL4k1
attach() => io // RTL4
attach() => io ChannelStateChange // RTL4
detach() => io // RTL5
history(
start: Time, // RTL10a
Expand All @@ -1937,9 +1939,9 @@ class RealtimeChannel: // RTL*
publish(Message) => io // RTL6, RTL6i
publish([Message]) => io // RTL6, RTL6i
publish(name: String?, data: Data?) => io // RTL6, RTL6i
subscribe((Message) ->) => io // RTL7, RTL7a
subscribe(String, (Message) ->) => io // RTL7, RTL7b
subscribe(MessageFilter, (Message) ->) // RTL22
subscribe((Message) ->) => io ChannelStateChange // RTL7, RTL7a
subscribe(String, (Message) ->) => io ChannelStateChange // RTL7, RTL7b
subscribe(MessageFilter, (Message) ->) io ChannelStateChange // RTL22
unsubscribe() // RTL8, RTL8c
unsubscribe((Message) ->) // RTL8, RTL8a
unsubscribe(String, (Message) ->) // RTL8, RTL8b
Expand Down

0 comments on commit 3a9499f

Please sign in to comment.