Skip to content

Commit

Permalink
Marked enter_local_members public instead of private
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Jun 25, 2024
1 parent 82ae801 commit 446a16f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
46 changes: 23 additions & 23 deletions lib/ably/realtime/presence/members_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion lib/ably/realtime/presence/presence_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 446a16f

Please sign in to comment.