Commit 52c99a43 authored by Steve Johnson's avatar Steve Johnson

initial fix for Chrome 38 - temporarily using wss://html5.cablelabs.com for non-secure websockets

parent 9f9f8ecf
......@@ -48,6 +48,7 @@ var Url = (function() {
request.issue(authURL, function(response){
if (response.httpStatus === 200) {
config = JSON.parse(response.responseText);
console.log("parsed config.json");
}
});
......@@ -150,12 +151,16 @@ var Url = (function() {
obj.wsBridge = function() {
var url;
if (config.wsBridgeURL) {
return config.wsBridgeURL;
url = config.wsBridgeURL;
}
else {
return "ws://" + document.location.host + ':1338';
//return "ws://" + document.location.host + ':1338';
url = "wss://" + document.location.host + ':1339';
}
console.log("Url.wsBridge: "+url);
return url;
};
obj.wssBridge = function() {
......
......@@ -31,11 +31,16 @@ var container = (function () {
var wsAdvertised = false;
var rcParams = {};
container.appID = "MSE";
var bridgeCode = "ABCD"; // used as shared device identifier.
var bridgeID = bridgeCode + ':' + container.appID;
var remoteDeviceCode = getDeviceCode();
var sharedDeviceCode = generateRandomCode();
container.wssID = "MSE-WSS";
var bridgeCode;
var bridgeID;
var wssBridgeID;
var remoteDeviceCode;
var sharedDeviceCode;
// Container States
var CS_IDLE = 0; // Idle state on startup
......@@ -61,7 +66,6 @@ var container = (function () {
var objRequest = new Object;
var objReply = new Object;
var rcParams = {};
// Add custom receiver objects
function addBridgeReceiverObject(id, obj) {
......@@ -70,6 +74,15 @@ var container = (function () {
container.onLoad = function() {
rcParams = queryParams();
bridgeCode = rcParams.bid ? rcParams.bid : "ABCD"; // used as shared device identifier.
bridgeID = bridgeCode + ':' + container.appID;
wssBridgeID = bridgeCode + ':' + container.wssID;
remoteDeviceCode = getDeviceCode();
sharedDeviceCode = generateRandomCode();
// Trying to fix iOS runaway resize in Navigator
var mobileAgent = window.mobilecheck();
// We inject both 'iphone' & simulated' into the user agent when running our OS X mseclient app. This
......@@ -93,16 +106,17 @@ var container = (function () {
wsBridgeURL = Url.wsBridge();
wssBridgeURL = Url.wssBridge();
rcParams = queryParams();
bridgeCode = rcParams.bid;
bridgeID = bridgeCode+":"+container.appID;
//bridgeID = bridgeCode+":"+container.appID; // already done
if (rcParams.wsURL != undefined) {
wsBridgeURL = rcParams.wsURL;
}
if (rcParams.wssURL != undefined) {
wssBridgeURL = rcParams.wssURL;
}
// Add application bid
rcParams['appBID'] = generateRandomCode();
......@@ -177,7 +191,7 @@ var container = (function () {
wssDirectory.onReceiveDevices = function(deviceList) {
var deviceApps = deviceList[bridgeCode];
for (index in deviceApps) {
if (deviceApps[index] == container.appID) {
if (deviceApps[index] == container.wssID) {
onWssAdvertised();
}
}
......@@ -320,7 +334,7 @@ var container = (function () {
// Connect to the secure websocket bridge
console.log("onWssAdvertised. Connecting..");
wssBridge.connect(wssBridgeURL, bridgeID + ':' + remoteDeviceCode);
wssBridge.connect(wssBridgeURL, wssBridgeID + ':' + remoteDeviceCode);
}
// Here with a secure websocket connection.
......@@ -366,7 +380,7 @@ var container = (function () {
}
container.onBridgeConnectFailure = function(error, bridge) {
dbgAlert("Unable to connect to bridge: \n" + error + "\n("+bridge+")");
console.log("Unable to connect to bridge: \n" + error + "\n("+bridge+")");
document.getElementById('ifr').src = "connectwait.html";
};
......
......@@ -218,7 +218,11 @@ var Remote = (function () {
parseDeviceList(qp.deviceList);
wsUrl = qp.wsURL ? qp.wsURL : Url.wsBridge();
// Too early - config.json not parsed yet. But remember query param if present.
if (qp.wsURL != undefined && qp.wsURL.indexOf("ws://") == -1) {
// Chrome 38 can't use ws:// and old client is hardwired for it as default bridge (ws://shareddom.ws:1338)
wsUrl = qp.wsURL;
}
buildMenu();
addDevices();
}
......@@ -1038,6 +1042,10 @@ var Remote = (function () {
}
function startApplication(appID, sessionToken) {
// wsUrl may have been presented via command line or setWsUrl. If not, read from the config file or use default.
wsUrl = wsUrl ? wsUrl : Url.wsBridge();
// Generate application bid
var bid = generateRandomCode();
......@@ -1051,7 +1059,26 @@ var Remote = (function () {
var app = applicationList[appID];
var bridgeUrl = standalone ? Dial.localBridgeUrl() : wsUrl;
var baseUrl = document.location.protocol + "//" + document.location.host+ "/";
// Broken, does not allow for base directory (eg. prod or dev)
//var baseUrl = document.location.protocol + "//" + document.location.host+ "/";
// Get the path for this script file, and determine grandparent (../../) directory (baseUrl)
var scriptEls = document.getElementsByTagName( 'script' );
var thisScriptEl = scriptEls[scriptEls.length - 1];
for (var i=0; i < scriptEls.length; i++) {
if (scriptEls[i].src.indexOf("/remote.js") != -1) {
thisScriptEl = scriptEls[i];
break;
}
}
var scriptPath = thisScriptEl.src;
var scriptFolder = scriptPath.substr(0, scriptPath.lastIndexOf( '/' ));
var htmlFolder = scriptFolder.substr(0, scriptFolder.lastIndexOf( '/' ));
var mseFolder = htmlFolder.substr(0, htmlFolder.lastIndexOf( '/' ));
var baseUrl = mseFolder.substr(0, mseFolder.lastIndexOf( '/' )+1);
var remoteUrl = app.remote.url;
var sharedUrl = app.shared.url;
......
......@@ -22,6 +22,7 @@ var container = (function () {
var wssBridge = null;
container.appID = "MSE";
container.wssID = "MSE-WSS";
// Container States
var CS_IDLE = 0; // Waiting for launch request
......@@ -53,6 +54,7 @@ var container = (function () {
if (qp.bid != undefined)
{
bridgeID = qp.bid+":"+container.appID;
wssBridgeID = qp.bid+":"+container.wssID;
}
if (qp.wsurl != undefined)
......@@ -173,8 +175,9 @@ var container = (function () {
// Here with request from remote for a secure websocket bridge connection
function onSecureSocketRequest(args) {
console.log("onSecureSocketRequest");
wssBridge.connect(args[K.requestKeyWebsocketURL], bridgeID);
var id = wssBridgeID;
console.log("onSecureSocketRequest. Advertising "+id);
wssBridge.connect(args[K.requestKeyWebsocketURL], id);
}
// Here with (wss) request from remote to launch an application
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment