Permalink
Browse files

mod_base: use wss (instead of ws) when we are on a https connection. …

…Fixes #436
  • Loading branch information...
1 parent e3efa0b commit 9051de10b661cf0e6f487e8f3250d515efcfc26b @mworrell mworrell committed Oct 2, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 modules/mod_base/lib/js/apps/zotonic-1.0.js
@@ -483,7 +483,7 @@ function z_stream_start(host)
{
if (!z_ws && !z_comet_is_running)
{
- if ("WebSocket" in window && window.location.protocol == "http:")
+ if ("WebSocket" in window)
{
z_websocket_start(host);
}
@@ -547,7 +547,12 @@ function z_comet_data(data)
function z_websocket_start(host)
{
- z_ws = new WebSocket("ws://"+document.location.host+"/websocket?z_pageid="+z_pageid);
+ var protocol = "ws:";
+ if (window.location.protocol == "https:")
+ {
+ protocol = "wss:";
+ }
+ z_ws = new WebSocket(protocol+"//"+document.location.host+"/websocket?z_pageid="+z_pageid);
z_ws.onopen = function() { z_ws_opened = true; };
z_ws.onerror = function() { };

0 comments on commit 9051de1

Please sign in to comment.