From 446a16fabb036ff135b765f0bcce5a88bf09b11e Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Tue, 25 Jun 2024 17:36:58 +0530 Subject: [PATCH] Marked enter_local_members public instead of private --- lib/ably/realtime/presence/members_map.rb | 46 +++++++++---------- .../realtime/presence/presence_manager.rb | 2 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/ably/realtime/presence/members_map.rb b/lib/ably/realtime/presence/members_map.rb index 49b006f6..5d3c46c2 100644 --- a/lib/ably/realtime/presence/members_map.rb +++ b/lib/ably/realtime/presence/members_map.rb @@ -152,6 +152,29 @@ def local_members @local_members end + def enter_local_members + local_members.values.each do |member| + local_client_id = member.client_id || client.auth.client_id + logger.debug { "#{self.class.name}: Manually re-entering local presence member, client ID: #{local_client_id} with data: #{member.data}" } + presence.enter_client_with_id(member.id, local_client_id, member.data).tap do |deferrable| + deferrable.errback do |error| + presence_message_client_id = member.client_id || client.auth.client_id + re_enter_error = Ably::Models::ErrorInfo.new( + message: "unable to automatically re-enter presence channel for client_id '#{presence_message_client_id}'. Source error code #{error.code} and message '#{error.message}'", + code: Ably::Exceptions::Codes::UNABLE_TO_AUTOMATICALLY_REENTER_PRESENCE_CHANNEL + ) + channel.emit :update, Ably::Models::ChannelStateChange.new( + current: channel.state, + previous: channel.state, + event: Ably::Realtime::Channel::EVENT(:update), + reason: re_enter_error, + resumed: true + ) + end + end + end + end + private attr_reader :sync_session_id @@ -226,29 +249,6 @@ def setup_event_handlers end end - def enter_local_members - local_members.values.each do |member| - local_client_id = member.client_id || client.auth.client_id - logger.debug { "#{self.class.name}: Manually re-entering local presence member, client ID: #{local_client_id} with data: #{member.data}" } - presence.enter_client_with_id(member.id, local_client_id, member.data).tap do |deferrable| - deferrable.errback do |error| - presence_message_client_id = member.client_id || client.auth.client_id - re_enter_error = Ably::Models::ErrorInfo.new( - message: "unable to automatically re-enter presence channel for client_id '#{presence_message_client_id}'. Source error code #{error.code} and message '#{error.message}'", - code: Ably::Exceptions::Codes::UNABLE_TO_AUTOMATICALLY_REENTER_PRESENCE_CHANNEL - ) - channel.emit :update, Ably::Models::ChannelStateChange.new( - current: channel.state, - previous: channel.state, - event: Ably::Realtime::Channel::EVENT(:update), - reason: re_enter_error, - resumed: true - ) - end - end - end - end - def update_members_and_emit_events(presence_message) return unless ensure_presence_message_is_valid(presence_message) diff --git a/lib/ably/realtime/presence/presence_manager.rb b/lib/ably/realtime/presence/presence_manager.rb index 75cc60b6..3a32a5e0 100644 --- a/lib/ably/realtime/presence/presence_manager.rb +++ b/lib/ably/realtime/presence/presence_manager.rb @@ -31,7 +31,7 @@ def on_attach(has_presence_flag) 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.send(:enter_local_members) # RTP17f + presence.members.enter_local_members # RTP17f end # Process presence messages from SYNC messages. Sync can be server-initiated or triggered following ATTACH