Class: WhereIsWaldo::RosterChannel
- Inherits:
-
ApplicationCable::Channel
- Object
- ActionCable::Channel::Base
- ApplicationCable::Channel
- WhereIsWaldo::RosterChannel
- Defined in:
- app/channels/where_is_waldo/roster_channel.rb
Overview
Roster subscription. The delivery mode is resolved per account at subscribe time (config.roster_mode) and dispatched to the matching RosterDelivery strategy; the client is told the mode via the snapshot and adapts (listen vs. poll). A subject can only ever see their OWN account's roster (org is derived from the authenticated connection), so it's safe by construction.
Modes:
:broadcast - stream_from the shared account stream; deltas are pushed.
:poll - no stream; the client calls #poll and gets a filtered diff.
Instance Method Summary collapse
-
#poll ⇒ Object
Client-driven poll (pull/nudge modes).
- #subscribed ⇒ Object
Instance Method Details
#poll ⇒ Object
Client-driven poll (pull/nudge modes). Transmits a filtered snapshot (first call / resync) or diff since the last poll for this session.
26 27 28 29 30 |
# File 'app/channels/where_is_waldo/roster_channel.rb', line 26 def poll return unless @wiw_strategy @wiw_strategy.(@wiw_subject, waldo_session_id).each { || transmit() } end |
#subscribed ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'app/channels/where_is_waldo/roster_channel.rb', line 14 def subscribed subject = current_subject mode = resolve_mode(subject) return reject unless mode @wiw_subject = subject @wiw_strategy = RosterDelivery.for(mode) apply_plan(@wiw_strategy.subscribe_plan(subject, waldo_session_id)) end |