Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ActionCable vs. Socket.io at ConFoo

Ray Hightower
December 07, 2016

ActionCable vs. Socket.io at ConFoo

How do you achieve real time, bi-directional, event-based communications in your apps? The Socket.io library is tested and true. ActionCable, new with Ruby on Rails version 5, is a challenger. Which solution is better, and why?

This presentation compares Socket.io and ActionCable (included w/Ruby on Rails version 5).

Ray Hightower

December 07, 2016
Tweet

More Decks by Ray Hightower

Other Decks in Technology

Transcript

  1. 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)
  2. 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
  3. 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
  4. The Remarkable Journey of a Single Web Request by Aaron

    Kalin https://windycityrails.com/videos/2015/#9
  5. +