Class: ChatChannel

Inherits:
ApplicationCable::Channel
  • Object
show all
Defined in:
lib/templates/chat_channel.rb

Instance Method Summary collapse

Instance Method Details

#receive(data) ⇒ Object



9
10
11
12
13
# File 'lib/templates/chat_channel.rb', line 9

def receive(data)
  data["time"] = Time.now.strftime("at %I:%M%p")
  ActionCable.server.broadcast("chat_#{params[:room]}", data)
  RubyBotJob.perform_later data,params[:room]
end

#subscribedObject

become a subscriber of this channel.



5
6
7
# File 'lib/templates/chat_channel.rb', line 5

def subscribed
  stream_from "chat_#{params[:room]}"
end