class Hippo::API::PubSub
Constants
- PREFIX
Public Class Methods
channel_prefix()
click to toggle source
# File lib/hippo/api/pub_sub.rb, line 28 def self.channel_prefix PREFIX end
publish(channel, data)
click to toggle source
# File lib/hippo/api/pub_sub.rb, line 23 def self.publish(channel, data) channel = channel_prefix + channel ActionCable.server.broadcast(channel, data.merge(channel: channel)) end
Public Instance Methods
channel_prefix()
click to toggle source
# File lib/hippo/api/pub_sub.rb, line 32 def channel_prefix PREFIX end
off(data)
click to toggle source
# File lib/hippo/api/pub_sub.rb, line 15 def off(data) channel = channel_prefix + data['channel'] subscribers = pubsub .instance_variable_get('@listener') .instance_variable_get('@subscribers')[channel] pubsub.unsubscribe(channel, subscribers.first) if subscribers.any? end
on(data)
click to toggle source
# File lib/hippo/api/pub_sub.rb, line 10 def on(data) Hippo.logger.info "pubsub on: #{data['channel']}" stream_from channel_prefix + data['channel'] end