Module: WhereIsWaldo
- Defined in:
- lib/where_is_waldo.rb,
lib/where_is_waldo/apm.rb,
lib/where_is_waldo/engine.rb,
lib/where_is_waldo/version.rb,
lib/where_is_waldo/configuration.rb,
app/models/where_is_waldo/presence.rb,
app/services/where_is_waldo/roster.rb,
app/jobs/where_is_waldo/application_job.rb,
app/services/where_is_waldo/broadcaster.rb,
app/channels/where_is_waldo/jwt_connection.rb,
app/channels/where_is_waldo/roster_channel.rb,
app/services/where_is_waldo/roster_delivery.rb,
app/channels/where_is_waldo/presence_channel.rb,
app/jobs/where_is_waldo/presence_cleanup_job.rb,
app/models/where_is_waldo/application_record.rb,
app/services/where_is_waldo/presence_service.rb,
app/models/concerns/where_is_waldo/broadcastable.rb,
app/services/where_is_waldo/adapters/base_adapter.rb,
app/services/where_is_waldo/adapters/redis_adapter.rb,
app/channels/where_is_waldo/application_cable/channel.rb,
app/services/where_is_waldo/adapters/database_adapter.rb,
lib/generators/where_is_waldo/install/install_generator.rb,
app/channels/where_is_waldo/application_cable/connection.rb
Defined Under Namespace
Modules: Adapters, Apm, ApplicationCable, Broadcastable, Generators, JwtConnection, RosterDelivery Classes: ApplicationJob, ApplicationRecord, Broadcaster, Configuration, Engine, Presence, PresenceChannel, PresenceCleanupJob, PresenceService, Roster, RosterChannel
Constant Summary collapse
- VERSION =
File.read(File.("../../VERSION", __dir__)).strip
Class Method Summary collapse
-
.all_online_ids(timeout: nil) ⇒ Object
Get all online subject IDs (no scope filtering).
-
.broadcast_to(scope, message_type, data = {}) ⇒ Object
Broadcast to subjects in a scope.
-
.broadcast_to_online(scope, message_type, data = {}) ⇒ Object
Broadcast only to online subjects in a scope.
-
.broadcast_to_session(session_id, message_type, data = {}) ⇒ Object
Broadcast to a specific session.
- .cleanup(timeout: nil) ⇒ Object
- .config ⇒ Object
- .configuration ⇒ Object
- .configure {|configuration| ... } ⇒ Object
-
.connect ⇒ Object
Presence Management ===.
- .disconnect ⇒ Object
- .heartbeat ⇒ Object
-
.online(scope, timeout: nil) ⇒ Object
Get online subjects from a scope.
-
.online_ids(scope, timeout: nil) ⇒ Object
Get online subject IDs from a scope.
-
.presence_on(subject_id, platform, timeout: nil) ⇒ Object
Presence status for a subject on a specific device/platform.
-
.publish_presence(subject_id, timeout: nil) ⇒ Object
Broadcast a compact presence delta for a subject to their org's roster stream.
- .reset_configuration! ⇒ Object
-
.roster_snapshot(org, timeout: nil) ⇒ Object
Full roster state for an org record (every member + current presence).
-
.roster_state_for(subject_id, timeout: nil) ⇒ Object
Aggregate presence state ({ status:, devices: }) for one subject.
-
.roster_stream_for(subject) ⇒ Object
Shared roster stream name for the org a subject belongs to.
- .session_status ⇒ Object
- .sessions_for_subject ⇒ Object
-
.subject_online? ⇒ Boolean
NOTE: don't use ActiveSupport's
delegatehere.
Class Method Details
.all_online_ids(timeout: nil) ⇒ Object
Get all online subject IDs (no scope filtering)
55 56 57 |
# File 'lib/where_is_waldo.rb', line 55 def all_online_ids(timeout: nil) PresenceService.all_online_ids(timeout: timeout) end |
.broadcast_to(scope, message_type, data = {}) ⇒ Object
Broadcast to subjects in a scope
116 117 118 |
# File 'lib/where_is_waldo.rb', line 116 def broadcast_to(scope, , data = {}) Broadcaster.broadcast_to(scope, , data) end |
.broadcast_to_online(scope, message_type, data = {}) ⇒ Object
Broadcast only to online subjects in a scope
122 123 124 |
# File 'lib/where_is_waldo.rb', line 122 def broadcast_to_online(scope, , data = {}) Broadcaster.broadcast_to_online(scope, , data) end |
.broadcast_to_session(session_id, message_type, data = {}) ⇒ Object
Broadcast to a specific session
128 129 130 |
# File 'lib/where_is_waldo.rb', line 128 def broadcast_to_session(session_id, , data = {}) Broadcaster.broadcast_to_session(session_id, , data) end |
.cleanup(timeout: nil) ⇒ Object
79 80 81 |
# File 'lib/where_is_waldo.rb', line 79 def cleanup(timeout: nil) PresenceService.cleanup(timeout: timeout) end |
.config ⇒ Object
18 19 20 |
# File 'lib/where_is_waldo.rb', line 18 def config configuration end |
.configuration ⇒ Object
10 11 12 |
# File 'lib/where_is_waldo.rb', line 10 def configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
14 15 16 |
# File 'lib/where_is_waldo.rb', line 14 def configure yield(configuration) end |
.connect ⇒ Object
Presence Management ===
28 29 30 |
# File 'lib/where_is_waldo.rb', line 28 def connect(...) PresenceService.connect(...) end |
.disconnect ⇒ Object
32 33 34 |
# File 'lib/where_is_waldo.rb', line 32 def disconnect(...) PresenceService.disconnect(...) end |
.heartbeat ⇒ Object
36 37 38 |
# File 'lib/where_is_waldo.rb', line 36 def heartbeat(...) PresenceService.heartbeat(...) end |
.online(scope, timeout: nil) ⇒ Object
Get online subjects from a scope
44 45 46 |
# File 'lib/where_is_waldo.rb', line 44 def online(scope, timeout: nil) PresenceService.online(scope, timeout: timeout) end |
.online_ids(scope, timeout: nil) ⇒ Object
Get online subject IDs from a scope
50 51 52 |
# File 'lib/where_is_waldo.rb', line 50 def online_ids(scope, timeout: nil) PresenceService.online_ids(scope, timeout: timeout) end |
.presence_on(subject_id, platform, timeout: nil) ⇒ Object
Presence status for a subject on a specific device/platform.
97 98 99 |
# File 'lib/where_is_waldo.rb', line 97 def presence_on(subject_id, platform, timeout: nil) Roster.device_status(subject_id, platform, timeout: timeout) end |
.publish_presence(subject_id, timeout: nil) ⇒ Object
Broadcast a compact presence delta for a subject to their org's roster stream. Call on transitions only (usually automatic via PresenceChannel).
103 104 105 |
# File 'lib/where_is_waldo.rb', line 103 def publish_presence(subject_id, timeout: nil) Roster.publish(subject_id, timeout: timeout) end |
.reset_configuration! ⇒ Object
22 23 24 |
# File 'lib/where_is_waldo.rb', line 22 def reset_configuration! @configuration = Configuration.new end |
.roster_snapshot(org, timeout: nil) ⇒ Object
Full roster state for an org record (every member + current presence).
86 87 88 |
# File 'lib/where_is_waldo.rb', line 86 def roster_snapshot(org, timeout: nil) Roster.snapshot(org, timeout: timeout) end |
.roster_state_for(subject_id, timeout: nil) ⇒ Object
Aggregate presence state ({ status:, devices: }) for one subject.
91 92 93 |
# File 'lib/where_is_waldo.rb', line 91 def roster_state_for(subject_id, timeout: nil) Roster.state_for(subject_id, timeout: timeout) end |
.roster_stream_for(subject) ⇒ Object
Shared roster stream name for the org a subject belongs to.
108 109 110 |
# File 'lib/where_is_waldo.rb', line 108 def roster_stream_for(subject) Roster.stream_for_subject(subject) end |
.session_status ⇒ Object
75 76 77 |
# File 'lib/where_is_waldo.rb', line 75 def session_status(...) PresenceService.session_status(...) end |
.sessions_for_subject ⇒ Object
71 72 73 |
# File 'lib/where_is_waldo.rb', line 71 def sessions_for_subject(...) PresenceService.sessions_for_subject(...) end |
.subject_online? ⇒ Boolean
NOTE: don't use ActiveSupport's delegate here. delegate generates
the method via class_eval with a STRING, and a string-eval'd body's
Module.nesting is just the target class — for a class << self inside
module WhereIsWaldo, that's [#<Class:WhereIsWaldo>], WITHOUT
WhereIsWaldo itself. Constant lookup for PresenceService inside the
generated method then can't walk up to the enclosing module and raises
uninitialized constant #<Class:WhereIsWaldo>::PresenceService. A plain
def inherits the enclosing lexical nesting and resolves correctly.
67 68 69 |
# File 'lib/where_is_waldo.rb', line 67 def subject_online?(...) PresenceService.subject_online?(...) end |