Slide 1

Slide 1 text

ActionCable vs. Socket.io @RayHightower ConFoo - Dec 5-7, 2016 Vancouver, BC Canada

Slide 2

Slide 2 text

What? Why? Examples. Comparison.

Slide 3

Slide 3 text

ActionCable is… •Real time. •Full duplex. •Event based.

Slide 4

Slide 4 text

Half Duplex Walkie-Talkie Full Duplex Phone

Slide 5

Slide 5 text

HTTP is stateless.

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

https://xkcd.com/869/

Slide 8

Slide 8 text

WebSocket Protocol

Slide 9

Slide 9 text

REmote DIctionary Server

Slide 10

Slide 10 text

In-memory Key-value store Dictionary Hash {

Slide 11

Slide 11 text

pub/sub

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Channels: Clients Rooms: Server

Slide 14

Slide 14 text

Create the app.

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Generate the rooms controller.

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Generate the channel.

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

Create a home for the messages in the database.

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Remember the migration!

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

1 Rails.application.routes.draw do 2 get 'rooms/show' 3 4 end 1 Rails.application.routes.draw do 2 root to: ‘rooms#show' 3 4 end config/routes.rb (before & after)

Slide 25

Slide 25 text

1 class RoomsController < ApplicationController 2 def show 3 @messages = Message.all 4 end 5 end app/controllers/rooms_controller.rb (before & after) 1 class RoomsController < ApplicationController 2 def show 3 end 4 end

Slide 26

Slide 26 text

app/channels/rooms_channel.rb 1 # Be sure to restart your server when you modify… 2 class RoomChannel < ApplicationCable::Channel 3 def subscribed 4 # stream_from "some_channel" 5 end 6 7 def unsubscribed 8 # Any cleanup needed when channel is unsubscribed 9 end 10 11 def speak 12 end 13 end

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

The Remarkable Journey of a Single Web Request by Aaron Kalin https://windycityrails.com/videos/2015/#9

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Another chat app?

Slide 31

Slide 31 text

Gartner Hype Cycle Image by Jeremy Kemp https://commons.wikimedia.org/wiki/File:Gartner_Hype_Cycle.svg

Slide 32

Slide 32 text

Gartner Hype Cycle ActionCable Slope of Enlightenment?

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

+

Slide 36

Slide 36 text

WebSockets and Robotics

Slide 37

Slide 37 text

Remotely Operated Vehicle

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

Browser BeagleBone Black Arduino Socket.io Serial Node.js Chrome C++

Slide 50

Slide 50 text

Browser BeagleBone Black Arduino ActionCable Serial Ruby Chrome C++

Slide 51

Slide 51 text

Comparison

Slide 52

Slide 52 text

•ActionCable is… •Socket.io is…

Slide 53

Slide 53 text

YACA OpenROV vs.

Slide 54

Slide 54 text

Fitness for a particular purpose.

Slide 55

Slide 55 text

Thanks! RayHightower.com