diff options
author | Matthew Draper <matthew@trebex.net> | 2016-01-22 11:13:51 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2016-01-24 15:52:47 +1030 |
commit | b17a7e4c4daa4ab54223b0c5e2d03b491c070e0e (patch) | |
tree | 10cc764f5c6d2c93ce34a38dd8d0334759544dbe /actioncable/lib/action_cable/subscription_adapter/inline.rb | |
parent | e81bb80cb4214ff795f7a2bb03f699e2a7f7d45a (diff) | |
download | rails-b17a7e4c4daa4ab54223b0c5e2d03b491c070e0e.tar.gz rails-b17a7e4c4daa4ab54223b0c5e2d03b491c070e0e.tar.bz2 rails-b17a7e4c4daa4ab54223b0c5e2d03b491c070e0e.zip |
Add Async and Inline adapters
Just like their ActiveJob equivalents, these only work within the
current process.
Diffstat (limited to 'actioncable/lib/action_cable/subscription_adapter/inline.rb')
-rw-r--r-- | actioncable/lib/action_cable/subscription_adapter/inline.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/actioncable/lib/action_cable/subscription_adapter/inline.rb b/actioncable/lib/action_cable/subscription_adapter/inline.rb new file mode 100644 index 0000000000..19747601be --- /dev/null +++ b/actioncable/lib/action_cable/subscription_adapter/inline.rb @@ -0,0 +1,22 @@ +module ActionCable + module SubscriptionAdapter + class Inline < Base # :nodoc: + def broadcast(channel, payload) + subscriber_map.broadcast(channel, payload) + end + + def subscribe(channel, callback, success_callback = nil) + subscriber_map.add_subscriber(channel, callback, success_callback) + end + + def unsubscribe(channel, callback) + subscriber_map.remove_subscriber(channel, callback) + end + + private + def subscriber_map + @subscriber_map ||= SubscriberMap.new + end + end + end +end |