1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actioncable/test/client/echo_channel.rb
Matthew Draper 786ed1b3ad Handle more IO errors (especially, ECONNRESET)
Also, address the possibility of the listen thread dying and needing to
be respawned. As a bonus, we now defer construction of the thread until
we are first given something to monitor.
2016-01-30 03:46:37 +10:30

18 lines
321 B
Ruby

class EchoChannel < ActionCable::Channel::Base
def subscribed
stream_from "global"
end
def ding(data)
transmit(dong: data['message'])
end
def delay(data)
sleep 1
transmit(dong: data['message'])
end
def bulk(data)
ActionCable.server.broadcast "global", wide: data['message']
end
end