Class: Ably::Rest::Presence
- Inherits:
-
Object
- Object
- Ably::Rest::Presence
- Includes:
- Modules::Conversions
- Defined in:
- lib/submodules/ably-ruby/lib/ably/rest/presence.rb
Overview
Enables the retrieval of the current and historic presence set for a channel.
Instance Attribute Summary collapse
-
#channel ⇒ Ably::Rest::Channel
readonly
Channel this Presence object is associated with.
-
#client ⇒ Ably::Rest::Client
readonly
Client for this Presence object.
Instance Method Summary collapse
-
#get(options = {}) ⇒ Ably::Models::PaginatedResult<Ably::Models::PresenceMessage>
Retrieves the current members present on the channel and the metadata for each member, such as their Models::PresenceMessage::ACTION and ID.
-
#history(options = {}) ⇒ Ably::Models::PaginatedResult<Ably::Models::PresenceMessage>
Retrieves a Models::PaginatedResult object, containing an array of historical Models::PresenceMessage objects for the channel.
-
#initialize(client, channel) ⇒ Presence
constructor
Initialize a new Presence object.
Constructor Details
#initialize(client, channel) ⇒ Presence
Initialize a new Presence object
26 27 28 29 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/presence.rb', line 26 def initialize(client, channel) @client = client @channel = channel end |
Instance Attribute Details
#channel ⇒ Ably::Rest::Channel (readonly)
Channel this Presence object is associated with
19 20 21 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/presence.rb', line 19 def channel @channel end |
#client ⇒ Ably::Rest::Client (readonly)
Client for this Presence object
13 14 15 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/presence.rb', line 13 def client @client end |
Instance Method Details
#get(options = {}) ⇒ Ably::Models::PaginatedResult<Ably::Models::PresenceMessage>
Retrieves the current members present on the channel and the metadata for each member, such as their Models::PresenceMessage::ACTION and ID. Returns a Models::PaginatedResult object, containing an array of Models::PresenceMessage objects.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/presence.rb', line 44 def get( = {}) = = { :limit => 100 }.merge() = { coerce_into: 'Ably::Models::PresenceMessage', async_blocking_operations: .delete(:async_blocking_operations), } response = client.get(base_path, ) Ably::Models::PaginatedResult.new(response, base_path, client, ) do || .tap do || end end end |
#history(options = {}) ⇒ Ably::Models::PaginatedResult<Ably::Models::PresenceMessage>
Retrieves a Models::PaginatedResult object, containing an array of historical Models::PresenceMessage objects for the channel. If the channel is configured to persist messages, then presence messages can be retrieved from history for up to 72 hours in the past. If not, presence messages can only be retrieved from history for up to two minutes in the past.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/presence.rb', line 77 def history( = {}) url = "#{base_path}/history" = = { :direction => :backwards, :limit => 100 }.merge() [:start, :end].each { |option| [option] = as_since_epoch([option]) if .has_key?(option) } raise ArgumentError, ":end must be equal to or after :start" if [:start] && [:end] && ([:start] > [:end]) = { coerce_into: 'Ably::Models::PresenceMessage', async_blocking_operations: .delete(:async_blocking_operations), } response = client.get(url, ) Ably::Models::PaginatedResult.new(response, url, client, ) do || .tap do || end end end |