blob: 82084b68fb52afd0a28db09cf2838641cb471dcd (
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_message: chat_message
})
end
def subscribed
stream_from "chat_room_channel"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
end
|