Class: ActionCable::SubscriptionAdapter::Redis

Inherits:
Base
  • Object
show all
Defined in:
actioncable/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


13
14
15
16
17
# File 'actioncable/lib/action_cable/subscription_adapter/redis.rb', line 13

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

Instance Method Details

#broadcast(channel, payload) ⇒ Object


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

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

#redis_connection_for_subscriptionsObject


35
36
37
# File 'actioncable/lib/action_cable/subscription_adapter/redis.rb', line 35

def redis_connection_for_subscriptions
  redis_connection
end

#shutdownObject


31
32
33
# File 'actioncable/lib/action_cable/subscription_adapter/redis.rb', line 31

def shutdown
  @listener.shutdown if @listener
end

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


23
24
25
# File 'actioncable/lib/action_cable/subscription_adapter/redis.rb', line 23

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

#unsubscribe(channel, callback) ⇒ Object


27
28
29
# File 'actioncable/lib/action_cable/subscription_adapter/redis.rb', line 27

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