2018-08-29 13:09:12 +00:00
|
|
|
class ChatRoomsController < ApplicationController
|
|
|
|
|
2018-08-30 02:00:09 +00:00
|
|
|
def show
|
2018-09-04 18:03:28 +00:00
|
|
|
require "google/cloud/translate"
|
|
|
|
|
2018-08-30 02:00:09 +00:00
|
|
|
@chat_room = ChatRoom.find(params[:id])
|
2018-09-04 18:03:28 +00:00
|
|
|
|
|
|
|
keyfile = ENV['TRANSLATION_CREDENTIALS']
|
|
|
|
creds = Google::Cloud::Translate::Credentials.new(keyfile)
|
|
|
|
|
|
|
|
translate = Google::Cloud::Translate.new(
|
|
|
|
project_id: ENV["PROJECT_ID"],
|
|
|
|
credentials: creds
|
|
|
|
)
|
|
|
|
|
|
|
|
@languages = translate.languages("en")
|
2018-08-30 02:00:09 +00:00
|
|
|
end
|
|
|
|
|
2018-08-29 13:09:12 +00:00
|
|
|
def create
|
2018-08-30 17:42:42 +00:00
|
|
|
# HTTP status code 200 with an empty body
|
|
|
|
head :no_content
|
|
|
|
puts ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>11123213213213123213"
|
|
|
|
puts params
|
|
|
|
puts ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>11123213213213123213"
|
2018-08-29 13:09:12 +00:00
|
|
|
|
2018-08-30 17:42:42 +00:00
|
|
|
ActionCable.server.broadcast "chat_room_#{params[:room]}", session_params
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def session_params
|
|
|
|
# SDP = Session description protocol (codec info from client)
|
|
|
|
# Candidate = ICE candidates (e.g. TURN and STUN server)
|
|
|
|
params.permit(:type, :from, :to, :sdp, :candidate, :room)
|
2018-08-29 13:09:12 +00:00
|
|
|
end
|
|
|
|
end
|