added chatroom channel with room ids and notifications channel

This commit is contained in:
Beatrice Olivera
2018-08-30 03:00:09 +01:00
parent f0bca74f89
commit 405d2cd5df
17 changed files with 699 additions and 25 deletions

View File

@@ -1,5 +1,9 @@
class ChatRoomsController < ApplicationController
def show
@chat_room = ChatRoom.find(params[:id])
end
def create
end

View File

@@ -1,5 +1,6 @@
class PagesController < ApplicationController
# skip_before_action :authenticate_user!, only: [:call]
skip_before_action :verify_authenticity_token
def call
end
@@ -9,4 +10,32 @@ class PagesController < ApplicationController
def home
end
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
end