IN A NUTSHELL
Server
Client
WebSocket
Client
WebSocket
stream C
Broadcaster
stream B
stream A
stream B
channel X
channel Y
channel Z
Slide 16
Slide 16 text
CHANNELS
class AnswersChannel < ApplicationCable ::Channel
def subscribed
reject_subscription unless current_user.admin?
end
def follow(params)
stream_from "questions/ #{params['id']}"
end
end
Slide 17
Slide 17 text
CABLE
HYPE
Slide 18
Slide 18 text
CABLE HYPE
Slide 19
Slide 19 text
PROS
&
CONS
Slide 20
Slide 20 text
CABLE PROS
Easy configuration
Slide 21
Slide 21 text
CABLE PROS
Easy configuration
Channels framework
Slide 22
Slide 22 text
CABLE PROS
Easy configuration
Channels framework
JS client that just works
Slide 23
Slide 23 text
CABLE CONS
Slide 24
Slide 24 text
CABLE CONS
Lack of transport fallbacks
Slide 25
Slide 25 text
WEBSOCKETS
http://caniuse.com/#search=websockets
Slide 26
Slide 26 text
CABLE CONS
Lack of transport fallbacks
Memory usage
Rails-free Action Cable
No deps (even ActiveSupport)
Compatible with AnyCable
Compatible with Action Cable JS
LITE CABLE
Slide 65
Slide 65 text
module Chat
class Channel < LiteCable ::Channel ::Base
identifier :chat
def subscribed
stream_from "chat_ #{chat_id}"
end
end
end
LITE CABLE
Slide 66
Slide 66 text
run Rack ::Builder.new do
map '/cable' do
use LiteCable ::Server ::Middleware,
connection_class: Chat ::Connection
run proc { |_| [200, {}, ['']] }
end
end
LITE CABLE