summaryrefslogtreecommitdiff
path: root/app/channels/chat_room_channel.rb
blob: 1e14b35976e86ccee537a0577adc5c38c00b5ba6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class ChatRoomChannel < ApplicationCable::Channel
  def self.broadcast_chat_message(chat_message)
    ActionCable.server.broadcast "chat_room_channel",
                                 html: ApplicationController.render(partial: "chat_messages/message",
                                                                    locals: {
                                                                      chat: chat_message
                                                                    })
  end

  def subscribed
    stream_from "chat_room_channel"
  end

  def unsubscribed
    # Any cleanup needed when channel is unsubscribed
  end
end