2018-08-30 02:00:09 +00:00
|
|
|
class ChatRoomsChannel < ApplicationCable::Channel
|
|
|
|
def subscribed
|
|
|
|
stream_from "chat_room_#{params[:room]}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def unsubscribed
|
|
|
|
# Any cleanup needed when channel is unsubscribed
|
2018-09-04 12:50:44 +00:00
|
|
|
puts "I am now destroyed"
|
|
|
|
# redirect_to root_path
|
|
|
|
# ActionCable.server.broadcast('notifications', {
|
|
|
|
# head: 302, # redirection code, just to make it clear what you're doing
|
|
|
|
# path: chat_room_path(chat_room), # you'll need to use url_helpers, so include them in your file
|
|
|
|
# body: { caller: other_caller.id }
|
|
|
|
# }
|
|
|
|
# redirect_to root_path
|
2018-08-30 02:00:09 +00:00
|
|
|
end
|
|
|
|
end
|