Class: ActionCable::SubscriptionAdapter::Redis

Inherits:
Base
  • Object
show all
Includes:
ChannelPrefix
Defined in:
lib/action_cable/subscription_adapter/redis.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Listener

Instance Attribute Summary

Attributes inherited from Base

#logger, #server

Instance Method Summary collapse

Constructor Details

#initializeRedis

Returns a new instance of Redis.



19
20
21
22
23
# File 'lib/action_cable/subscription_adapter/redis.rb', line 19

def initialize(*)
  super
  @listener = nil
  @redis_connection_for_broadcasts = nil
end

Instance Method Details

#broadcast(channel, payload) ⇒ Object



25
26
27
# File 'lib/action_cable/subscription_adapter/redis.rb', line 25

def broadcast(channel, payload)
  redis_connection_for_broadcasts.publish(channel, payload)
end

#redis_connection_for_subscriptionsObject



41
42
43
# File 'lib/action_cable/subscription_adapter/redis.rb', line 41

def redis_connection_for_subscriptions
  redis_connection
end

#shutdownObject



37
38
39
# File 'lib/action_cable/subscription_adapter/redis.rb', line 37

def shutdown
  @listener.shutdown if @listener
end

#subscribe(channel, callback, success_callback = nil) ⇒ Object



29
30
31
# File 'lib/action_cable/subscription_adapter/redis.rb', line 29

def subscribe(channel, callback, success_callback = nil)
  listener.add_subscriber(channel, callback, success_callback)
end

#unsubscribe(channel, callback) ⇒ Object



33
34
35
# File 'lib/action_cable/subscription_adapter/redis.rb', line 33

def unsubscribe(channel, callback)
  listener.remove_subscriber(channel, callback)
end