Class: ChatChannel

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

Instance Method Summary collapse

Instance Method Details

#send_message(data) ⇒ Object



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

def send_message(data)
  content = data['message']
  chat_id = data['chat_id']
  chat = Chat.find(chat_id)
  ChatService.create_message(chat, content, current_user)
end

#subscribedObject



2
3
4
5
# File 'lib/templates/chat/chat_channel.rb', line 2

def subscribed
  chat = Chat.find(params[:chat_id])
  stream_for(chat)
end

#unsubscribedObject



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

def unsubscribed; end