lib/submodules/ably-ruby/lib/ably/realtime/presence/members_map.rb in ably-rest-0.8.6 vs lib/submodules/ably-ruby/lib/ably/realtime/presence/members_map.rb in ably-rest-0.8.9

- old
+ new

@@ -58,12 +58,12 @@ end # Get the list of presence members # # @param [Hash,String] options an options Hash to filter members - # @option options [String] :client_id optional client_id for the member - # @option options [String] :connection_id optional connection_id for the member + # @option options [String] :client_id optional client_id filter for the member + # @option options [String] :connection_id optional connection_id filter for the member # @option options [String] :wait_for_sync defaults to false, if true the get method waits for the initial presence sync following channel attachment to complete before returning the members present # # @yield [Array<Ably::Models::PresenceMessage>] array of present members # # @return [Ably::Util::SafeDeferrable] Deferrable that supports both success (callback) and failure (errback) callbacks @@ -97,16 +97,16 @@ reset_callbacks deferrable.fail error end reset_callbacks = proc do - off &in_sync_callback - off &failed_callback - channel.off &failed_callback + off(&in_sync_callback) + off(&failed_callback) + channel.off(&failed_callback) end - once :in_sync, &in_sync_callback + once(:in_sync, &in_sync_callback) once(:failed, &failed_callback) channel.unsafe_once(:detaching, :detached, :failed) do |error_reason| failed_callback.call error_reason end @@ -129,12 +129,26 @@ return to_enum(:each) unless block_given? present_members.each(&block) end private - attr_reader :members, :sync_serial, :presence, :absent_member_cleanup_queue + def members + @members + end + def sync_serial + @sync_serial + end + + def presence + @presence + end + + def absent_member_cleanup_queue + @absent_member_cleanup_queue + end + def channel presence.channel end def client @@ -154,12 +168,12 @@ presence_message.decode channel update_members_and_emit_events presence_message end resume_sync_proc = method(:resume_sync).to_proc - connection.on_resume &resume_sync_proc + connection.on_resume(&resume_sync_proc) once(:in_sync, :failed) do - connection.off_resume &resume_sync_proc + connection.off_resume(&resume_sync_proc) end once(:in_sync) do clean_up_absent_members end