polyglot/app/controllers/chat_rooms_controller.rb

44 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

2018-08-29 13:09:12 +00:00
class ChatRoomsController < ApplicationController
def show
require "google/cloud/translate"
@chat_room = ChatRoom.find(params[:id])
keyfile = ENV['TRANSLATION_CREDENTIALS']
creds = Google::Cloud::Translate::Credentials.new(keyfile)
translate = Google::Cloud::Translate.new(
project_id: ENV["PROJECT_ID"],
credentials: creds
)
2018-09-05 12:07:43 +00:00
@languages = translate.languages("en")
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
2018-09-04 12:50:44 +00:00
def destroy
# chat_room = ChatRoom.find(params[:id])
# chat_room.destroy
ActionCable.server.broadcast "chat_room_#{params[:id]}", { hangUp: true }
head :ok
end
2018-08-30 17:42:42 +00:00
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