Get websocket protocol from config file to avoid frustration in local installing

This commit is contained in:
Tom Staubitz
2015-12-12 00:43:04 +08:00
parent 943d5554d9
commit 38bfa4b1f5

View File

@ -169,7 +169,6 @@ $(function() {
}
}
// setAnnotations(editors[i], $(editors[i].container).data('id'));
console.log('location: #{Time.now}' + window.location.port);
}
// toggle button states (it might be the case that the request for comments button has to be enabled
toggleButtonStates();
@ -1121,7 +1120,8 @@ $(function() {
var initWebsocketConnection = function(url) {
//TODO: get the protocol from config file dependent on environment. (dev: ws, prod: wss)
//causes: Puma::HttpParserError: Invalid HTTP format, parsing fails.
websocket = new WebSocket('ws://' + window.location.hostname + ':' + window.location.port + url);
//TODO: make sure that this gets cached.
websocket = new WebSocket('<%= DockerClient.config['ws_client_protocol'] %>' + window.location.hostname + ':' + window.location.port + url);
websocket.onopen = function(evt) { resetOutputTab(); }; // todo show some kind of indicator for established connection
websocket.onclose = function(evt) { /* expected at some point */ };
websocket.onmessage = function(evt) { parseCanvasMessage(evt.data, true); };