diff --git a/ably/realtime_channel.go b/ably/realtime_channel.go index 84469845..2d1c6c57 100644 --- a/ably/realtime_channel.go +++ b/ably/realtime_channel.go @@ -269,13 +269,23 @@ func newRealtimeChannel(name string, client *Realtime, chOptions *channelOptions return c } +// RTL3 func (c *RealtimeChannel) onConnStateChange(change ConnectionStateChange) { + if change.Current == ConnectionStateConnected { + c.queue.Flush() //RTL3d + } + chState := c.State() + if chState != ChannelStateAttaching && chState != ChannelStateAttached { + return + } switch change.Current { - case ConnectionStateConnected: - c.queue.Flush() case ConnectionStateFailed: c.setState(ChannelStateFailed, change.Reason, false) c.queue.Fail(change.Reason) + case ConnectionStateClosed: + c.setState(ChannelStateDetached, nil, false) + case ConnectionStateSuspended: + c.setState(ChannelStateSuspended, nil, false) } } diff --git a/ably/realtime_client.go b/ably/realtime_client.go index 56de739a..c37125ae 100644 --- a/ably/realtime_client.go +++ b/ably/realtime_client.go @@ -89,7 +89,7 @@ func (c *Realtime) onChannelMsg(msg *protocolMessage) { func (c *Realtime) onReconnected(failedResumeOrRecover bool) { for _, ch := range c.Channels.Iterate() { switch ch.State() { - // RTN15g3, RTN15c6, RTN15c7, RTN16l + // RTN15g3, RTN15c6, RTN15c7, RTN16l, RTL3d case ChannelStateAttaching, ChannelStateAttached, ChannelStateSuspended: ch.mayAttach(false) case ChannelStateDetaching: //RTN19b diff --git a/ably/realtime_presence.go b/ably/realtime_presence.go index e93192bd..c7f8be16 100644 --- a/ably/realtime_presence.go +++ b/ably/realtime_presence.go @@ -57,7 +57,7 @@ func (pres *RealtimePresence) isValidChannelState() error { } } -// RTP5a +// RTP5a, RTP16b, RTL11 func (pres *RealtimePresence) onChannelDetachedOrFailed(err error) { for k := range pres.members { delete(pres.members, k) @@ -68,7 +68,7 @@ func (pres *RealtimePresence) onChannelDetachedOrFailed(err error) { pres.queue.Fail(err) } -// RTP5f, RTP16b +// RTP5f, RTP16b, RTL11 func (pres *RealtimePresence) onChannelSuspended(err error) { pres.queue.Fail(err) }