mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-20 07:05:05 -04:00
Merge remote-tracking branch 'fork/customise_server_port' into add_device_pairing
This commit is contained in:
commit
f9a22e5ae4
1 changed files with 7 additions and 7 deletions
|
@ -16,9 +16,9 @@ const { uniqueNamesGenerator, animals, colors } = require('unique-names-generato
|
||||||
|
|
||||||
class SnapdropServer {
|
class SnapdropServer {
|
||||||
|
|
||||||
constructor(port) {
|
constructor(host, port) {
|
||||||
const WebSocket = require('ws');
|
const WebSocket = require('ws');
|
||||||
this._wss = new WebSocket.Server({ port: port });
|
this._wss = new WebSocket.Server({ host: host, port: port });
|
||||||
this._wss.on('connection', (socket, request) => this._onConnection(new Peer(socket, request)));
|
this._wss.on('connection', (socket, request) => this._onConnection(new Peer(socket, request)));
|
||||||
this._wss.on('headers', (headers, response) => this._onHeaders(headers, response));
|
this._wss.on('headers', (headers, response) => this._onHeaders(headers, response));
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class SnapdropServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onMessage(sender, message) {
|
_onMessage(sender, message) {
|
||||||
// Try to parse message
|
// Try to parse message
|
||||||
try {
|
try {
|
||||||
message = JSON.parse(message);
|
message = JSON.parse(message);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -176,7 +176,7 @@ class Peer {
|
||||||
this._setPeerId(request)
|
this._setPeerId(request)
|
||||||
// is WebRTC supported ?
|
// is WebRTC supported ?
|
||||||
this.rtcSupported = request.url.indexOf('webrtc') > -1;
|
this.rtcSupported = request.url.indexOf('webrtc') > -1;
|
||||||
// set name
|
// set name
|
||||||
this._setName(request);
|
this._setName(request);
|
||||||
// for keepalive
|
// for keepalive
|
||||||
this.timerId = 0;
|
this.timerId = 0;
|
||||||
|
@ -223,11 +223,11 @@ class Peer {
|
||||||
|
|
||||||
|
|
||||||
let deviceName = '';
|
let deviceName = '';
|
||||||
|
|
||||||
if (ua.os && ua.os.name) {
|
if (ua.os && ua.os.name) {
|
||||||
deviceName = ua.os.name.replace('Mac OS', 'Mac') + ' ';
|
deviceName = ua.os.name.replace('Mac OS', 'Mac') + ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ua.device.model) {
|
if (ua.device.model) {
|
||||||
deviceName += ua.device.model;
|
deviceName += ua.device.model;
|
||||||
} else {
|
} else {
|
||||||
|
@ -302,4 +302,4 @@ Object.defineProperty(String.prototype, 'hashCode', {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const server = new SnapdropServer(process.env.PORT || 3000);
|
const server = new SnapdropServer(process.env.HOST || null, process.env.PORT || 3000);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue