diff --git a/ably/realtime_channel.go b/ably/realtime_channel.go index 07a8d8aa..51997937 100644 --- a/ably/realtime_channel.go +++ b/ably/realtime_channel.go @@ -800,11 +800,11 @@ func (c *RealtimeChannel) notify(msg *protocolMessage) { if c.State() == ChannelStateAttached { if !msg.Flags.Has(flagResumed) { // RTL12 - c.Presence.onAttach(msg, true) + c.Presence.onAttach(msg) c.emitErrorUpdate(newErrorFromProto(msg.Error), false) } } else { - c.Presence.onAttach(msg, true) + c.Presence.onAttach(msg) c.setState(ChannelStateAttached, newErrorFromProto(msg.Error), msg.Flags.Has(flagResumed)) } c.queue.Flush() diff --git a/ably/realtime_presence.go b/ably/realtime_presence.go index 21bd2f80..c830651b 100644 --- a/ably/realtime_presence.go +++ b/ably/realtime_presence.go @@ -160,7 +160,7 @@ func (pres *RealtimePresence) enterMembers(internalMembers []*PresenceMessage) { } } -func (pres *RealtimePresence) onAttach(msg *protocolMessage, isAttachWithoutMessageLoss bool) { +func (pres *RealtimePresence) onAttach(msg *protocolMessage) { pres.mtx.Lock() defer pres.mtx.Unlock() // RTP1 @@ -173,18 +173,17 @@ func (pres *RealtimePresence) onAttach(msg *protocolMessage, isAttachWithoutMess close(pres.syncDone) } } - pres.queue.Flush() // RTP5b + // RTP5b + pres.queue.Flush() // RTP17f - if isAttachWithoutMessageLoss { - if len(pres.internalMembers) > 0 { - internalMembers := make([]*PresenceMessage, len(pres.internalMembers)) - indexCounter := 0 - for _, member := range pres.internalMembers { - internalMembers[indexCounter] = member - indexCounter = indexCounter + 1 - } - go pres.enterMembers(internalMembers) + if len(pres.internalMembers) > 0 { + internalMembers := make([]*PresenceMessage, len(pres.internalMembers)) + indexCounter := 0 + for _, member := range pres.internalMembers { + internalMembers[indexCounter] = member + indexCounter = indexCounter + 1 } + go pres.enterMembers(internalMembers) } }