Browse Source

Make socket connect to same protocol as page

pull/54/head
Amir Sanni 6 years ago
parent
commit
cae612a6fa
  1. BIN
      img/vidbg.png
  2. 11
      js/comm.js
  3. 4
      ws/bin/server.php

BIN
img/vidbg.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

11
js/comm.js

@ -18,9 +18,16 @@ var myPC; @@ -18,9 +18,16 @@ var myPC;
var awaitingResponse;
var streamConstraints;
var myMediaStream;
let wsChat;
const room = getRoom();
const wsChat = new WebSocket("ws://localhost:8080/comm");
if(location.protocol === 'http:'){
wsChat = new WebSocket("ws://1410inc.xyz/ws/comm");
}
else{
wsChat = new WebSocket("wss://1410inc.xyz/wss/comm");
}
window.addEventListener('load', function(){
startCounter();//shows the time spent in room

4
ws/bin/server.php

@ -12,10 +12,10 @@ require(realpath(dirname(__FILE__) . '/../') .'/vendor/autoload.php'); @@ -12,10 +12,10 @@ require(realpath(dirname(__FILE__) . '/../') .'/vendor/autoload.php');
use Amir\Comm;
//set an array of origins allowed to connect to this server
$allowed_origins = ['localhost', '127.0.0.1'];
$allowed_origins = ['localhost', '127.0.0.1', '1410inc.xyz', 'www.1410inc.xyz'];
// Run the server application through the WebSocket protocol on port 8080
$app = new Ratchet\App('localhost', 8080, '0.0.0.0');//App(hostname, port, 'whoCanConnectIP', '')
$app = new Ratchet\App('1410inc.xyz', 8080, '0.0.0.0');//App(hostname, port, 'whoCanConnectIP', '')
//create socket routes
//route(uri, classInstance, arrOfAllowedOrigins)

Loading…
Cancel
Save