2018-08-27 14:37:06 +00:00
|
|
|
class PagesController < ApplicationController
|
2018-08-28 13:46:15 +00:00
|
|
|
# skip_before_action :authenticate_user!, only: [:call]
|
2018-08-30 02:00:09 +00:00
|
|
|
skip_before_action :verify_authenticity_token
|
2018-08-27 14:37:06 +00:00
|
|
|
|
2018-08-28 12:48:32 +00:00
|
|
|
def call
|
2018-08-27 14:37:06 +00:00
|
|
|
end
|
2018-08-28 16:18:58 +00:00
|
|
|
|
|
|
|
def index
|
|
|
|
end
|
2018-08-28 16:21:12 +00:00
|
|
|
|
2018-08-28 14:00:54 +00:00
|
|
|
def home
|
|
|
|
end
|
2018-08-30 02:00:09 +00:00
|
|
|
|
|
|
|
def cable_testing
|
|
|
|
chatroom = 'chat_room_' + params[:chat_room_id]
|
|
|
|
puts params
|
|
|
|
ActionCable.server.broadcast(chatroom, { message: 'test' })
|
|
|
|
head :ok
|
|
|
|
end
|
|
|
|
|
|
|
|
def establish_call
|
|
|
|
head :ok
|
|
|
|
puts "params: #{params}"
|
|
|
|
chat_room = ChatRoom.create!
|
|
|
|
puts "Created chat room with id: #{chat_room.id}"
|
|
|
|
chat_room_participation = ChatRoomParticipation.create!(chat_room: chat_room, user: current_user)
|
|
|
|
puts "Created chat room participation with user: #{current_user.email} assigned to chat_room #{chat_room.id}"
|
|
|
|
puts "Subscribed user to chat room"
|
|
|
|
|
|
|
|
contact = User.find(params[:contact_id])
|
|
|
|
request = Request.create!(chat_room: chat_room, user: contact)
|
|
|
|
puts "Made a request to call #{contact.email}"
|
|
|
|
ActionCable.server.broadcast('notifications', {
|
|
|
|
message: {
|
|
|
|
user_id: contact.id,
|
|
|
|
chat_room_id: chat_room.id
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
end
|
2018-08-27 14:37:06 +00:00
|
|
|
end
|