Class: Ably::Realtime::Presence::PresenceManager Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ably/realtime/presence/presence_manager.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

PresenceManager is responsible for all actions relating to presence state

This is a private class and should never be used directly by developers as the API is likely to change in future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(presence) ⇒ PresenceManager

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PresenceManager.



16
17
18
19
20
# File 'lib/ably/realtime/presence/presence_manager.rb', line 16

def initialize(presence)
  @presence = presence

  setup_channel_event_handlers
end

Instance Attribute Details

#presenceAbly::Realtime::Presence (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Ably::Realtime::Presence this Manager is associated with



14
15
16
# File 'lib/ably/realtime/presence/presence_manager.rb', line 14

def presence
  @presence
end

Instance Method Details

#sync_expectedvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Expect SYNC ProtocolMessages from the server with a list of current members on this channel



27
28
29
# File 'lib/ably/realtime/presence/presence_manager.rb', line 27

def sync_expected
  presence.members.change_state :sync_starting
end

#sync_not_expectedvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

There server has indicated that there are no SYNC ProtocolMessages to come because there are no members on this channel



56
57
58
59
# File 'lib/ably/realtime/presence/presence_manager.rb', line 56

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

#sync_process_messages(serial, presence_messages) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Process presence messages from SYNC messages. Sync can be server-initiated or triggered following ATTACH



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ably/realtime/presence/presence_manager.rb', line 36

def sync_process_messages(serial, presence_messages)
  unless presence.members.sync_starting?
    presence.members.change_state :sync_starting
  end

  presence.members.update_sync_serial serial

  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