dynamically select websocket protocol

This commit is contained in:
Josh 2018-06-21 10:57:20 -04:00
parent 54adff3779
commit ad7aaa1a11
3 changed files with 18 additions and 1 deletions

View File

@ -6,7 +6,11 @@
//= require_tree ./channels
(function() {
var protocol = (window.location.protocol === "https:" ? "wss://" : "ws://");
var host = window.GreenLight.WEBSOCKET_HOST || window.location.host + window.GreenLight.RELATIVE_ROOT;
var url = protocol + host + '/cable';
this.App || (this.App = {});
App.cable = ActionCable.createConsumer();
App.cable = ActionCable.createConsumer(url);
}).call(this);

View File

@ -18,6 +18,12 @@ class ApplicationController < ActionController::Base
end
helper_method :user_name_limit
# Relative root helper (when deploying to subdirectory).
def relative_root
Rails.configuration.relative_url_root || ""
end
helper_method :relative_root
# Determines if the BigBlueButton endpoint is configured (or set to default).
def bigbluebutton_endpoint_default?
return false if loadbalanced_configuration?

View File

@ -6,6 +6,13 @@
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
<!-- Global javascript variables and helpers. -->
<script type="text/javascript">
window.GreenLight = {};
window.GreenLight.WEBSOCKET_HOST = "<%= ENV['WEBSOCKET_HOST'] %>"
window.GreenLight.RELATIVE_ROOT = "<%= relative_root %>"
</script>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>