Skip to content
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmota committed May 8, 2017
1 parent 26ff7a0 commit 57a9667
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
17 changes: 3 additions & 14 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function genRandString() {
});
}

function serverCallback(req, res) {
function callback(req, res) {
const path = req.url;

// index
Expand Down Expand Up @@ -49,10 +49,6 @@ function serverCallback(req, res) {
}
}

function wsCallback(req, res) {
res.send();
}

function createSock(path) {
const clients = [];
const sock = shoe(stream => {
Expand Down Expand Up @@ -99,23 +95,16 @@ function createSock(path) {
});
});

sock.install(wsServer, `${path}___`);
sock.install(server, `${path}___`);
sock.clients = clients;

return sock;
}


const server = http.createServer(serverCallback);
const server = http.createServer(callback);
const port = process.env.PORT || 8956;

server.listen(port, () => {
console.log(`Listening on port ${port}`);
});

const wsServer = http.createServer(wsCallback);
const wsPort = 8957;

wsServer.listen(wsPort, () => {
console.log(`Websocket listening on port ${wsPort}`);
});
5 changes: 2 additions & 3 deletions static/scripts/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -9148,9 +9148,8 @@ const fileToBase64 = require('filetobase64');
const base64Mime = require('base64mime');
const base64ToBlob = require('base64toblob');

const wsPort = 8957;
const {pathname, hostname, protocol} = window.location;
const stream = shoe(`${protocol}//${hostname}:8957${pathname}___`);
const {pathname, host, protocol} = window.location;
const stream = shoe(`${protocol}//${host}/ws/${pathname}___`);

const log = document.querySelector(`#log`);
const form = document.querySelector(`#form`);
Expand Down
5 changes: 2 additions & 3 deletions static/scripts/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ const fileToBase64 = require('filetobase64');
const base64Mime = require('base64mime');
const base64ToBlob = require('base64toblob');

const wsPort = 8957;
const {pathname, hostname, protocol} = window.location;
const stream = shoe(`${protocol}//${hostname}:8957${pathname}___`);
const {pathname, host, protocol} = window.location;
const stream = shoe(`${protocol}//${host}/ws/${pathname}___`);

const log = document.querySelector(`#log`);
const form = document.querySelector(`#form`);
Expand Down

0 comments on commit 57a9667

Please sign in to comment.