lib/submodules/ably-ruby/lib/ably/realtime/presence/presence_manager.rb in ably-rest-1.2.4 vs lib/submodules/ably-ruby/lib/ably/realtime/presence/presence_manager.rb in ably-rest-1.2.6
- old
+ new
@@ -17,17 +17,23 @@
@presence = presence
setup_channel_event_handlers
end
- # Expect SYNC ProtocolMessages from the server with a list of current members on this channel
- #
- # @return [void]
- #
# @api private
- def sync_expected
- presence.members.change_state :sync_starting
+ def on_attach(has_presence_flag)
+ # RTP1
+ if has_presence_flag
+ # Expect SYNC ProtocolMessages from the server with a list of current members on this channel
+ presence.members.change_state :sync_starting
+ else
+ # There server has indicated that there are no SYNC ProtocolMessages to come because
+ # there are no members on this channel
+ logger.debug { "#{self.class.name}: Emitting leave events for all members as a SYNC is not expected and thus there are no members on the channel" }
+ presence.members.change_state :sync_none
+ end
+ presence.members.enter_local_members # RTP17f
end
# Process presence messages from SYNC messages. Sync can be server-initiated or triggered following ATTACH
#
# @return [void]
@@ -43,20 +49,9 @@
presence_messages.each do |presence_message|
presence.__incoming_msgbus__.publish :sync, presence_message
end
presence.members.change_state :finalizing_sync if presence.members.sync_serial_cursor_at_end?
- end
-
- # There server has indicated that there are no SYNC ProtocolMessages to come because
- # there are no members on this channel
- #
- # @return [void]
- #
- # @api private
- def sync_not_expected
- logger.debug { "#{self.class.name}: Emitting leave events for all members as a SYNC is not expected and thus there are no members on the channel" }
- presence.members.change_state :sync_none
end
private
def_delegators :presence, :members, :channel