Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// var express = require('express');
var PeerServer = require('peer').PeerServer,
express = require('express'),
Topics = require('./app/src/Topics.js'),
app = express(),
port = process.env.PORT || 3001;
app.use(express.static(__dirname + '/public'));
var expressServer = app.listen(port);
var io = require('socket.io').listen(expressServer);
console.log('Listening on port', port);
var peerServer = new PeerServer({ port: 9000, path: '/chat' });
peerServer.on('connection', function (id) {
io.emit(Topics.USER_CONNECTED, id);
console.log('User connected with #', id);
});
peerServer.on('disconnect', function (id) {
io.emit(Topics.USER_DISCONNECTED, id);
console.log('User disconnected with #', id);
});
// var routes = require('./routes');
// var app = express();
var server = app.listen(4004, function(){
var host = server.address().address;
var port = server.address().port;
console.log("Collab App listening at http://%s:%s ~~~", host, port);
});
app.use("/public", express.static(path.resolve('public')));
/* peer js server */
var PeerServer = require('peer').PeerServer;
var pserver = PeerServer({port: 9000, path: '/myapp'});
pserver.on('connection', function(id) {
console.log("peer connected: ", id);
});
pserver.on('disconnect', function(id) {
console.log("peer disconnected: ", id);
});
var rooms = {names: {}, next_doc_id: 1, docs: {}};
//
var http = require('http'),
app = http.createServer(handler)
, io = require('socket.io').listen(app)
, fs = require('fs'),
staticHeaders = { host: 'localhost',
connection: 'keep-alive',
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.4 (KHTML, like Gecko) Ubuntu/12.10 Chromium/22.0.1229.94 Chrome/22.0.1229.94 Safari/537.4',
accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'accept-encoding': 'gzip,deflate,sdch',
'accept-language': 'en-GB,en-US;q=0.8,en;q=0.6',
'accept-charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3' };
app.listen(port);
// Peerjs Broker Server
var PeerServer = require('peer').PeerServer;
var peerServer = new PeerServer({ port: 9000 });
console.log("Server started listening on port "+port);
console.log("Go to http://localhost:"+port+"/game.html");
console.log();
function handler (req, res) {
var url = req.url;
if (url === "/")
url = "/index.html";
else if (url.substr(0, 6) === '/proxy') {
handleProxy(req, res);
return;
}
var fullPath = __dirname + '/../client' + url;
fs.stat(fullPath, function (err, stats) {
if (!err) {
/*
* Set up bindings for real server.
* Handle handshake between clientServer and clientBrowser
*/
/* Load in dependencies */
var config = require('getconfig'),
http = require('http'),
fs = require('fs');
var app = require('express')();
/* Create the peer server for the app */
var PeerServer = require('peer').PeerServer;
var peerServer = new PeerServer({ port: 9000, debug: true });
/* Create the file server for the app */
var server = require('http').createServer(app);
var port = process.env.PORT || config.server.port || 5000;
/* Start the server at the port. */
server.listen(port, function() {
console.log('Server running at port ' + port);
});
/* Static file mappings */
app.param('filename');
app.get('/server', function(req, res) {
res.sendfile(__dirname + '/server/index.html');
});
// depthPixelIndex += 2;
// }
// azureCtx.putImageData(depthImageData, 0, 0);
// };
// const map = (value, inputMin, inputMax, outputMin, outputMax) => {
// return (
// ((value - inputMin) * (outputMax - outputMin)) / (inputMax - inputMin) +
// outputMin
// );
// };
// Create local peer server
var PeerServer = require("peer").PeerServer;
var server = PeerServer({ port: 9001, path: "/" });
// Set peer credentials for localhost by default
var peerNet = { host: "localhost", port: 9001, path: "/" };
var myPeerId = "kinectron";
var peer_ids = [];
var peer_connections = [];
var peer = null;
var peerIdDisplay = null;
var newPeerEntry = false;
var newPeerInfo;
var canvas = null;
var context = null;
var canvasState = null;
const WINDOWSCOLORWIDTH = 1920;
XDmvcServer.prototype.startPeerSever = function(port){
//Start the PeerJS Server
var pserver = new PeerServer({
port: port,
allow_discovery: true
});
var that = this;
/*
pserver.on('connection', function(id) {
console.log("user connected via PeerJS. ID: " + id);
that.addPeerJsPeer(id);
that.emit("connected", id);
});
*/
pserver.on('disconnect', function(id) {
var deviceId = Object.keys(that.peerJsPeers).filter(function(key){
return that.peerJsPeers[key].peerId == id;
})[0];
'use strict';
var PeerServer = require('peer').PeerServer;
var express = require('express');
var Topics = require('./public/src/Topics.js');
var app = express();
var port = process.env.PORT || 3001;
app.use(express.static(__dirname + '/public'));
var expressServer = app.listen(port);
var io = require('socket.io').listen(expressServer);
console.log('Listening on port', port);
var peerServer = new PeerServer({ port: 9000, path: '/chat' });
peerServer.on('connection', function (id) {
io.emit(Topics.USER_CONNECTED, id);
console.log('User connected with #', id);
});
peerServer.on('disconnect', function (id) {
io.emit(Topics.USER_DISCONNECTED, id);
console.log('With #', id, 'user disconnected.');
});
})
.boolean('allow_discovery')
.argv;
try {
if (opts.sslkey && opts.sslcert) {
opts['ssl'] = {};
opts.ssl['key'] = fs.readFileSync(path.resolve(opts.sslkey));
opts.ssl['certificate'] = fs.readFileSync(path.resolve(opts.sslcert));
}
} catch (e) {
throw new ServerException(e);
}
try {
var server = new PeerServer(opts);
} catch (e) {
throw new ServerException(e);
}
console.log('Started RTCServer, port: ' + opts.port + ', path: ' + opts.path);
var PeerServer = require('peer').PeerServer;
var server = new PeerServer({ port: 9000 });
var tab_verif_connected = [];//Ce tableau verifi les followed qui son connectés
var io = require('socket.io').listen(8080,{ log: false }) ;
var fs = require('fs');
var jsonfile = require('jsonfile')
var util = require('util')
var file = 'user_list.json';
jsonfile.readFile(__dirname+'/'+file, function(err, obj) { console.log(obj)
if(obj==undefined){
}))
})
}
if (message.toLowerCase() === 'stop' && share === true) {
if (user === currentScreenUser) { //Only lets user stop their own
wss.clients.forEach(function each(client) {
client.send(JSON.stringify({
status: 'findStop',
userId: userID
})) //Finds person who stopped share
})
}
}
})
var server = PeerServer({
port: peerPort,
ssl: {
key: key,
cert: cert
},
path: '/peerjs'
})
var options = {
key: key,
cert: cert
}
var app = express()
var httpsServer = https.createServer(options, app)
httpsServer.listen(expressPort)