node-datachannel 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/lint.yml +22 -0
- package/CMakeLists.txt +2 -2
- package/examples/client-server/client-benchmark.js +43 -32
- package/examples/client-server/client-periodic.js +30 -14
- package/examples/client-server/client.js +6 -5
- package/examples/client-server/package-lock.json +183 -44
- package/examples/client-server/signaling-server.js +3 -5
- package/examples/media/media.js +9 -9
- package/lib/index.d.ts +100 -100
- package/node_modules/lru-cache/package.json +2 -4
- package/node_modules/minimist/package.json +0 -1
- package/node_modules/node-abi/node_modules/semver/README.md +3 -1
- package/node_modules/node-abi/node_modules/semver/bin/semver.js +19 -9
- package/node_modules/node-abi/node_modules/semver/classes/comparator.js +3 -2
- package/node_modules/node-abi/node_modules/semver/classes/index.js +1 -1
- package/node_modules/node-abi/node_modules/semver/classes/range.js +31 -22
- package/node_modules/node-abi/node_modules/semver/classes/semver.js +1 -1
- package/node_modules/node-abi/node_modules/semver/functions/cmp.js +8 -4
- package/node_modules/node-abi/node_modules/semver/functions/coerce.js +3 -2
- package/node_modules/node-abi/node_modules/semver/functions/inc.js +4 -1
- package/node_modules/node-abi/node_modules/semver/functions/parse.js +1 -1
- package/node_modules/node-abi/node_modules/semver/internal/constants.js +2 -2
- package/node_modules/node-abi/node_modules/semver/internal/identifiers.js +1 -1
- package/node_modules/node-abi/node_modules/semver/internal/parse-options.js +3 -3
- package/node_modules/node-abi/node_modules/semver/internal/re.js +3 -3
- package/node_modules/node-abi/node_modules/semver/package.json +51 -18
- package/node_modules/node-abi/node_modules/semver/ranges/min-version.js +2 -1
- package/node_modules/node-abi/node_modules/semver/ranges/outside.js +1 -1
- package/node_modules/node-abi/node_modules/semver/ranges/simplify.js +15 -12
- package/node_modules/node-abi/node_modules/semver/ranges/subset.js +53 -31
- package/node_modules/npmlog/node_modules/are-we-there-yet/package.json +10 -10
- package/node_modules/npmlog/package.json +1 -1
- package/node_modules/tar-stream/node_modules/bl/.travis.yml +4 -3
- package/node_modules/tar-stream/node_modules/bl/BufferList.js +1 -1
- package/node_modules/tar-stream/node_modules/bl/package.json +10 -10
- package/node_modules/tar-stream/node_modules/bl/test/test.js +20 -2
- package/node_modules/wide-align/LICENSE +0 -0
- package/node_modules/wide-align/README.md +0 -0
- package/node_modules/wide-align/align.js +0 -0
- package/node_modules/wide-align/package.json +14 -14
- package/package.json +2 -2
- package/src/data-channel-wrapper.cpp +69 -53
- package/src/data-channel-wrapper.h +0 -1
- package/src/media-track-wrapper.cpp +91 -52
- package/src/media-track-wrapper.h +0 -1
- package/src/peer-connection-wrapper.cpp +106 -70
- package/src/peer-connection-wrapper.h +0 -2
- package/test/connectivity.js +18 -17
- package/test/test.js +22 -30
- package/node_modules/node-abi/node_modules/semver/CHANGELOG.md +0 -111
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: Lint
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v3
|
|
17
|
+
- name: Use Node.js
|
|
18
|
+
uses: actions/setup-node@v3
|
|
19
|
+
with:
|
|
20
|
+
node-version: '16.x'
|
|
21
|
+
- run: npm ci
|
|
22
|
+
- run: npm run lint
|
package/CMakeLists.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
cmake_minimum_required(VERSION 3.15)
|
|
2
2
|
cmake_policy(SET CMP0091 NEW)
|
|
3
|
-
project(node_datachannel VERSION 0.3.
|
|
3
|
+
project(node_datachannel VERSION 0.3.2)
|
|
4
4
|
|
|
5
5
|
# Workaround for https://github.com/murat-dogan/node-datachannel/issues/65
|
|
6
6
|
if( NODE_RUNTIMEVERSION VERSION_GREATER_EQUAL "17.0.0")
|
|
@@ -33,7 +33,7 @@ include(FetchContent)
|
|
|
33
33
|
FetchContent_Declare(
|
|
34
34
|
libdatachannel
|
|
35
35
|
GIT_REPOSITORY https://github.com/paullouisageneau/libdatachannel.git
|
|
36
|
-
GIT_TAG "v0.17.
|
|
36
|
+
GIT_TAG "v0.17.3"
|
|
37
37
|
)
|
|
38
38
|
|
|
39
39
|
option(NO_MEDIA "Disable media transport support in libdatachannel" OFF)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
+
const yargs = require('yargs/yargs');
|
|
3
|
+
const { hideBin } = require('yargs/helpers');
|
|
3
4
|
const nodeDataChannel = require('../../lib/index');
|
|
4
5
|
const WebSocket = require('ws');
|
|
5
|
-
const readline = require(
|
|
6
|
+
const readline = require('readline');
|
|
6
7
|
|
|
7
8
|
// Init Logger
|
|
8
9
|
nodeDataChannel.initLogger('Debug');
|
|
@@ -26,38 +27,36 @@ const argv = yargs(hideBin(process.argv))
|
|
|
26
27
|
.option('disableSend', {
|
|
27
28
|
type: 'boolean',
|
|
28
29
|
description: 'Disable Send',
|
|
29
|
-
default: false
|
|
30
|
+
default: false,
|
|
30
31
|
})
|
|
31
32
|
.option('wsUrl', {
|
|
32
33
|
type: 'string',
|
|
33
34
|
description: 'Web Socket URL',
|
|
34
|
-
default: 'ws://localhost:8000'
|
|
35
|
+
default: 'ws://localhost:8000',
|
|
35
36
|
})
|
|
36
37
|
.option('dataChannelCount', {
|
|
37
38
|
type: 'number',
|
|
38
39
|
description: 'Data Channel Count To Create',
|
|
39
|
-
default: 1
|
|
40
|
-
})
|
|
41
|
-
.argv;
|
|
40
|
+
default: 1,
|
|
41
|
+
}).argv;
|
|
42
42
|
|
|
43
43
|
// Disable Send
|
|
44
|
-
const disableSend = argv.disableSend
|
|
44
|
+
const disableSend = argv.disableSend;
|
|
45
45
|
if (disableSend) console.log('Send Disabled!');
|
|
46
46
|
|
|
47
47
|
// Signaling Server
|
|
48
48
|
const wsUrl = process.env.WS_URL || argv.wsUrl;
|
|
49
|
-
console.log(wsUrl)
|
|
49
|
+
console.log(wsUrl);
|
|
50
50
|
const dataChannelCount = argv.dataChannelCount;
|
|
51
51
|
|
|
52
52
|
// Read Line Interface
|
|
53
53
|
const rl = readline.createInterface({
|
|
54
54
|
input: process.stdin,
|
|
55
|
-
output: process.stdout
|
|
55
|
+
output: process.stdout,
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
|
|
59
58
|
const ws = new WebSocket(wsUrl + '/' + id, {
|
|
60
|
-
perMessageDeflate: false
|
|
59
|
+
perMessageDeflate: false,
|
|
61
60
|
});
|
|
62
61
|
|
|
63
62
|
console.log(`The local ID is: ${id}`);
|
|
@@ -104,7 +103,7 @@ function readUserInput() {
|
|
|
104
103
|
let dcArrItem = {
|
|
105
104
|
dc: null,
|
|
106
105
|
bytesSent: 0,
|
|
107
|
-
bytesReceived: 0
|
|
106
|
+
bytesReceived: 0,
|
|
108
107
|
};
|
|
109
108
|
console.log('Creating DataChannel with label "test-' + i + '"');
|
|
110
109
|
dcArrItem.dc = pcMap[peerId].createDataChannel('test-' + i);
|
|
@@ -112,16 +111,16 @@ function readUserInput() {
|
|
|
112
111
|
dcArrItem.dc.setBufferedAmountLowThreshold(BUFFER_SIZE);
|
|
113
112
|
dcArrItem.dc.onOpen(() => {
|
|
114
113
|
while (!disableSend && dcArrItem.dc.bufferedAmount() <= BUFFER_SIZE) {
|
|
115
|
-
dcArrItem.dc.sendMessage(msgToSend)
|
|
116
|
-
dcArrItem.bytesSent += msgToSend.length
|
|
117
|
-
}
|
|
114
|
+
dcArrItem.dc.sendMessage(msgToSend);
|
|
115
|
+
dcArrItem.bytesSent += msgToSend.length;
|
|
116
|
+
}
|
|
118
117
|
});
|
|
119
118
|
|
|
120
119
|
dcArrItem.dc.onBufferedAmountLow(() => {
|
|
121
120
|
while (!disableSend && dcArrItem.dc.bufferedAmount() <= BUFFER_SIZE) {
|
|
122
|
-
dcArrItem.dc.sendMessage(msgToSend)
|
|
123
|
-
dcArrItem.bytesSent += msgToSend.length
|
|
124
|
-
}
|
|
121
|
+
dcArrItem.dc.sendMessage(msgToSend);
|
|
122
|
+
dcArrItem.bytesSent += msgToSend.length;
|
|
123
|
+
}
|
|
125
124
|
});
|
|
126
125
|
|
|
127
126
|
dcArrItem.dc.onMessage((msg) => {
|
|
@@ -131,23 +130,36 @@ function readUserInput() {
|
|
|
131
130
|
dcArr.push(dcArrItem);
|
|
132
131
|
}
|
|
133
132
|
|
|
134
|
-
|
|
135
133
|
// Report
|
|
136
134
|
let i = 0;
|
|
137
135
|
setInterval(() => {
|
|
138
136
|
let totalBytesSent = 0;
|
|
139
137
|
let totalBytesReceived = 0;
|
|
140
138
|
for (let j = 0; j < dcArr.length; j++) {
|
|
141
|
-
console.log(
|
|
139
|
+
console.log(
|
|
140
|
+
`${j == 0 ? i + '#' : ''} DC-${j + 1} Sent: ${byte2KB(
|
|
141
|
+
dcArr[j].bytesSent,
|
|
142
|
+
)} KB/s / Received: ${byte2KB(dcArr[j].bytesReceived)} KB/s / SendBufferAmount: ${dcArr[
|
|
143
|
+
j
|
|
144
|
+
].dc.bufferedAmount()} / DataChannelOpen: ${dcArr[j].dc.isOpen()}`,
|
|
145
|
+
);
|
|
142
146
|
totalBytesSent += dcArr[j].bytesSent;
|
|
143
147
|
totalBytesReceived += dcArr[j].bytesReceived;
|
|
144
148
|
dcArr[j].bytesSent = 0;
|
|
145
149
|
dcArr[j].bytesReceived = 0;
|
|
146
150
|
}
|
|
147
|
-
console.log(
|
|
151
|
+
console.log(
|
|
152
|
+
`Total Sent: ${byte2KB(totalBytesSent)} KB/s / Total Received: ${byte2KB(
|
|
153
|
+
totalBytesReceived,
|
|
154
|
+
)} KB/s`,
|
|
155
|
+
);
|
|
148
156
|
|
|
149
157
|
if (i % 5 == 0) {
|
|
150
|
-
console.log(
|
|
158
|
+
console.log(
|
|
159
|
+
`Stats# Sent: ${byte2MB(pcMap[peerId].bytesSent())} MB / Received: ${byte2MB(
|
|
160
|
+
pcMap[peerId].bytesReceived(),
|
|
161
|
+
)} MB / rtt: ${pcMap[peerId].rtt()} ms`,
|
|
162
|
+
);
|
|
151
163
|
console.log(`Selected Candidates# ${JSON.stringify(pcMap[peerId].getSelectedCandidatePair())}`);
|
|
152
164
|
console.log(``);
|
|
153
165
|
}
|
|
@@ -179,16 +191,15 @@ function createPeerConnection(peerId) {
|
|
|
179
191
|
let msgToSend = randomId(MESSAGE_SIZE);
|
|
180
192
|
|
|
181
193
|
while (!disableSend && dc.bufferedAmount() <= BUFFER_SIZE) {
|
|
182
|
-
dc.sendMessage(msgToSend)
|
|
183
|
-
}
|
|
194
|
+
dc.sendMessage(msgToSend);
|
|
195
|
+
}
|
|
184
196
|
|
|
185
197
|
dc.onBufferedAmountLow(() => {
|
|
186
198
|
while (!disableSend && dc.bufferedAmount() <= BUFFER_SIZE) {
|
|
187
|
-
dc.sendMessage(msgToSend)
|
|
188
|
-
}
|
|
199
|
+
dc.sendMessage(msgToSend);
|
|
200
|
+
}
|
|
189
201
|
});
|
|
190
202
|
|
|
191
|
-
|
|
192
203
|
dc.onMessage((msg) => {
|
|
193
204
|
// bytesReceived += msg.length;
|
|
194
205
|
});
|
|
@@ -208,9 +219,9 @@ function randomId(length) {
|
|
|
208
219
|
}
|
|
209
220
|
|
|
210
221
|
function byte2KB(bytes) {
|
|
211
|
-
return `${Math.round(bytes / 1000)}
|
|
222
|
+
return `${Math.round(bytes / 1000)}`;
|
|
212
223
|
}
|
|
213
224
|
|
|
214
225
|
function byte2MB(bytes) {
|
|
215
|
-
return `${Math.round(bytes / (1000 * 1000))}
|
|
216
|
-
}
|
|
226
|
+
return `${Math.round(bytes / (1000 * 1000))}`;
|
|
227
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
1
2
|
const nodeDataChannel = require('../../lib/index');
|
|
2
3
|
const WebSocket = require('ws');
|
|
3
|
-
const readline = require(
|
|
4
|
+
const readline = require('readline');
|
|
4
5
|
|
|
5
6
|
// Init Logger
|
|
6
7
|
nodeDataChannel.initLogger('Debug');
|
|
@@ -20,13 +21,13 @@ const BUFFER_SIZE = MESSAGE_SIZE * 10;
|
|
|
20
21
|
// Read Line Interface
|
|
21
22
|
const rl = readline.createInterface({
|
|
22
23
|
input: process.stdin,
|
|
23
|
-
output: process.stdout
|
|
24
|
+
output: process.stdout,
|
|
24
25
|
});
|
|
25
26
|
|
|
26
27
|
// Signaling Server
|
|
27
|
-
const WS_URL = process.env.WS_URL ||
|
|
28
|
+
const WS_URL = process.env.WS_URL || 'ws://localhost:8000';
|
|
28
29
|
const ws = new WebSocket(WS_URL + '/' + id, {
|
|
29
|
-
perMessageDeflate: false
|
|
30
|
+
perMessageDeflate: false,
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
console.log(`The local ID is: ${id}`);
|
|
@@ -77,7 +78,7 @@ function readUserInput() {
|
|
|
77
78
|
dc.onOpen(() => {
|
|
78
79
|
setInterval(() => {
|
|
79
80
|
if (dc.bufferedAmount() <= BUFFER_SIZE) {
|
|
80
|
-
dc.sendMessage(msgToSend)
|
|
81
|
+
dc.sendMessage(msgToSend);
|
|
81
82
|
bytesSent += msgToSend.length;
|
|
82
83
|
}
|
|
83
84
|
}, 2);
|
|
@@ -90,13 +91,21 @@ function readUserInput() {
|
|
|
90
91
|
// Report
|
|
91
92
|
let i = 0;
|
|
92
93
|
setInterval(() => {
|
|
93
|
-
console.log(
|
|
94
|
+
console.log(
|
|
95
|
+
`${i++}# Sent: ${byte2KB(bytesSent)} KB/s / Received: ${byte2KB(
|
|
96
|
+
bytesReceived,
|
|
97
|
+
)} KB/s / SendBufferAmount: ${dc.bufferedAmount()} / DataChannelOpen: ${dc.isOpen()}`,
|
|
98
|
+
);
|
|
94
99
|
bytesSent = 0;
|
|
95
100
|
bytesReceived = 0;
|
|
96
101
|
}, 1000);
|
|
97
102
|
|
|
98
103
|
setInterval(() => {
|
|
99
|
-
console.log(
|
|
104
|
+
console.log(
|
|
105
|
+
`Stats# Sent: ${byte2MB(pcMap[peerId].bytesSent())} MB / Received: ${byte2MB(
|
|
106
|
+
pcMap[peerId].bytesReceived(),
|
|
107
|
+
)} MB / rtt: ${pcMap[peerId].rtt()} ms`,
|
|
108
|
+
);
|
|
100
109
|
console.log(`Selected Candidates# ${JSON.stringify(pcMap[peerId].getSelectedCandidatePair())}`);
|
|
101
110
|
console.log(``);
|
|
102
111
|
}, 5 * 1000);
|
|
@@ -129,12 +138,11 @@ function createPeerConnection(peerId) {
|
|
|
129
138
|
|
|
130
139
|
setInterval(() => {
|
|
131
140
|
if (dc.bufferedAmount() <= BUFFER_SIZE) {
|
|
132
|
-
dc.sendMessage(msgToSend)
|
|
141
|
+
dc.sendMessage(msgToSend);
|
|
133
142
|
bytesSent += msgToSend.length;
|
|
134
143
|
}
|
|
135
144
|
}, 2);
|
|
136
145
|
|
|
137
|
-
|
|
138
146
|
dc.onMessage((msg) => {
|
|
139
147
|
bytesReceived += msg.length;
|
|
140
148
|
});
|
|
@@ -142,13 +150,21 @@ function createPeerConnection(peerId) {
|
|
|
142
150
|
// Report
|
|
143
151
|
let i = 0;
|
|
144
152
|
setInterval(() => {
|
|
145
|
-
console.log(
|
|
153
|
+
console.log(
|
|
154
|
+
`${i++}# Sent: ${byte2KB(bytesSent)} KB/s / Received: ${byte2KB(
|
|
155
|
+
bytesReceived,
|
|
156
|
+
)} KB/s / SendBufferAmount: ${dc.bufferedAmount()} / DataChannelOpen: ${dc.isOpen()}`,
|
|
157
|
+
);
|
|
146
158
|
bytesSent = 0;
|
|
147
159
|
bytesReceived = 0;
|
|
148
160
|
}, 1000);
|
|
149
161
|
|
|
150
162
|
setInterval(() => {
|
|
151
|
-
console.log(
|
|
163
|
+
console.log(
|
|
164
|
+
`Stats# Sent: ${byte2MB(pcMap[peerId].bytesSent())} MB / Received: ${byte2MB(
|
|
165
|
+
pcMap[peerId].bytesReceived(),
|
|
166
|
+
)} MB / rtt: ${pcMap[peerId].rtt()} ms`,
|
|
167
|
+
);
|
|
152
168
|
console.log(`Selected Candidates# ${JSON.stringify(pcMap[peerId].getSelectedCandidatePair())}`);
|
|
153
169
|
console.log(``);
|
|
154
170
|
}, 5 * 1000);
|
|
@@ -168,9 +184,9 @@ function randomId(length) {
|
|
|
168
184
|
}
|
|
169
185
|
|
|
170
186
|
function byte2KB(bytes) {
|
|
171
|
-
return `${Math.round(bytes / 1024)}
|
|
187
|
+
return `${Math.round(bytes / 1024)}`;
|
|
172
188
|
}
|
|
173
189
|
|
|
174
190
|
function byte2MB(bytes) {
|
|
175
|
-
return `${Math.round(bytes / (1024 * 1024))}
|
|
176
|
-
}
|
|
191
|
+
return `${Math.round(bytes / (1024 * 1024))}`;
|
|
192
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
1
2
|
const nodeDataChannel = require('../../lib/index');
|
|
2
3
|
const WebSocket = require('ws');
|
|
3
|
-
const readline = require(
|
|
4
|
+
const readline = require('readline');
|
|
4
5
|
|
|
5
6
|
// Init Logger
|
|
6
7
|
nodeDataChannel.initLogger('Error');
|
|
@@ -12,9 +13,9 @@ const pcMap = {};
|
|
|
12
13
|
const id = randomId(4);
|
|
13
14
|
|
|
14
15
|
// Signaling Server
|
|
15
|
-
const WS_URL = process.env.WS_URL ||
|
|
16
|
+
const WS_URL = process.env.WS_URL || 'ws://localhost:8000';
|
|
16
17
|
const ws = new WebSocket(WS_URL + '/' + id, {
|
|
17
|
-
perMessageDeflate: false
|
|
18
|
+
perMessageDeflate: false,
|
|
18
19
|
});
|
|
19
20
|
|
|
20
21
|
console.log(`The local ID is: ${id}`);
|
|
@@ -52,7 +53,7 @@ function readUserInput() {
|
|
|
52
53
|
// Read Line Interface
|
|
53
54
|
const rl = readline.createInterface({
|
|
54
55
|
input: process.stdin,
|
|
55
|
-
output: process.stdout
|
|
56
|
+
output: process.stdout,
|
|
56
57
|
});
|
|
57
58
|
|
|
58
59
|
rl.question('Enter a remote ID to send an offer:\n', (peerId) => {
|
|
@@ -110,4 +111,4 @@ function randomId(length) {
|
|
|
110
111
|
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
111
112
|
}
|
|
112
113
|
return result;
|
|
113
|
-
}
|
|
114
|
+
}
|
|
@@ -1,26 +1,192 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "client",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"lockfileVersion":
|
|
4
|
+
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "client",
|
|
9
|
+
"version": "1.0.0",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"ws": "^7.5.3",
|
|
13
|
+
"yargs": "^16.2.0"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"node_modules/ansi-regex": {
|
|
17
|
+
"version": "5.0.0",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=8"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"node_modules/ansi-styles": {
|
|
24
|
+
"version": "4.3.0",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"color-convert": "^2.0.1"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=8"
|
|
31
|
+
},
|
|
32
|
+
"funding": {
|
|
33
|
+
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"node_modules/cliui": {
|
|
37
|
+
"version": "7.0.4",
|
|
38
|
+
"license": "ISC",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"string-width": "^4.2.0",
|
|
41
|
+
"strip-ansi": "^6.0.0",
|
|
42
|
+
"wrap-ansi": "^7.0.0"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"node_modules/color-convert": {
|
|
46
|
+
"version": "2.0.1",
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"color-name": "~1.1.4"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=7.0.0"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"node_modules/color-name": {
|
|
56
|
+
"version": "1.1.4",
|
|
57
|
+
"license": "MIT"
|
|
58
|
+
},
|
|
59
|
+
"node_modules/emoji-regex": {
|
|
60
|
+
"version": "8.0.0",
|
|
61
|
+
"license": "MIT"
|
|
62
|
+
},
|
|
63
|
+
"node_modules/escalade": {
|
|
64
|
+
"version": "3.1.1",
|
|
65
|
+
"license": "MIT",
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": ">=6"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"node_modules/get-caller-file": {
|
|
71
|
+
"version": "2.0.5",
|
|
72
|
+
"license": "ISC",
|
|
73
|
+
"engines": {
|
|
74
|
+
"node": "6.* || 8.* || >= 10.*"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"node_modules/is-fullwidth-code-point": {
|
|
78
|
+
"version": "3.0.0",
|
|
79
|
+
"license": "MIT",
|
|
80
|
+
"engines": {
|
|
81
|
+
"node": ">=8"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"node_modules/require-directory": {
|
|
85
|
+
"version": "2.1.1",
|
|
86
|
+
"license": "MIT",
|
|
87
|
+
"engines": {
|
|
88
|
+
"node": ">=0.10.0"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"node_modules/string-width": {
|
|
92
|
+
"version": "4.2.2",
|
|
93
|
+
"license": "MIT",
|
|
94
|
+
"dependencies": {
|
|
95
|
+
"emoji-regex": "^8.0.0",
|
|
96
|
+
"is-fullwidth-code-point": "^3.0.0",
|
|
97
|
+
"strip-ansi": "^6.0.0"
|
|
98
|
+
},
|
|
99
|
+
"engines": {
|
|
100
|
+
"node": ">=8"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"node_modules/strip-ansi": {
|
|
104
|
+
"version": "6.0.0",
|
|
105
|
+
"license": "MIT",
|
|
106
|
+
"dependencies": {
|
|
107
|
+
"ansi-regex": "^5.0.0"
|
|
108
|
+
},
|
|
109
|
+
"engines": {
|
|
110
|
+
"node": ">=8"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"node_modules/wrap-ansi": {
|
|
114
|
+
"version": "7.0.0",
|
|
115
|
+
"license": "MIT",
|
|
116
|
+
"dependencies": {
|
|
117
|
+
"ansi-styles": "^4.0.0",
|
|
118
|
+
"string-width": "^4.1.0",
|
|
119
|
+
"strip-ansi": "^6.0.0"
|
|
120
|
+
},
|
|
121
|
+
"engines": {
|
|
122
|
+
"node": ">=10"
|
|
123
|
+
},
|
|
124
|
+
"funding": {
|
|
125
|
+
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"node_modules/ws": {
|
|
129
|
+
"version": "7.5.3",
|
|
130
|
+
"license": "MIT",
|
|
131
|
+
"engines": {
|
|
132
|
+
"node": ">=8.3.0"
|
|
133
|
+
},
|
|
134
|
+
"peerDependencies": {
|
|
135
|
+
"bufferutil": "^4.0.1",
|
|
136
|
+
"utf-8-validate": "^5.0.2"
|
|
137
|
+
},
|
|
138
|
+
"peerDependenciesMeta": {
|
|
139
|
+
"bufferutil": {
|
|
140
|
+
"optional": true
|
|
141
|
+
},
|
|
142
|
+
"utf-8-validate": {
|
|
143
|
+
"optional": true
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"node_modules/y18n": {
|
|
148
|
+
"version": "5.0.8",
|
|
149
|
+
"license": "ISC",
|
|
150
|
+
"engines": {
|
|
151
|
+
"node": ">=10"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"node_modules/yargs": {
|
|
155
|
+
"version": "16.2.0",
|
|
156
|
+
"license": "MIT",
|
|
157
|
+
"dependencies": {
|
|
158
|
+
"cliui": "^7.0.2",
|
|
159
|
+
"escalade": "^3.1.1",
|
|
160
|
+
"get-caller-file": "^2.0.5",
|
|
161
|
+
"require-directory": "^2.1.1",
|
|
162
|
+
"string-width": "^4.2.0",
|
|
163
|
+
"y18n": "^5.0.5",
|
|
164
|
+
"yargs-parser": "^20.2.2"
|
|
165
|
+
},
|
|
166
|
+
"engines": {
|
|
167
|
+
"node": ">=10"
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"node_modules/yargs-parser": {
|
|
171
|
+
"version": "20.2.7",
|
|
172
|
+
"license": "ISC",
|
|
173
|
+
"engines": {
|
|
174
|
+
"node": ">=10"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
},
|
|
6
178
|
"dependencies": {
|
|
7
179
|
"ansi-regex": {
|
|
8
|
-
"version": "5.0.0"
|
|
9
|
-
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
|
|
10
|
-
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg=="
|
|
180
|
+
"version": "5.0.0"
|
|
11
181
|
},
|
|
12
182
|
"ansi-styles": {
|
|
13
183
|
"version": "4.3.0",
|
|
14
|
-
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
|
15
|
-
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
|
16
184
|
"requires": {
|
|
17
185
|
"color-convert": "^2.0.1"
|
|
18
186
|
}
|
|
19
187
|
},
|
|
20
188
|
"cliui": {
|
|
21
189
|
"version": "7.0.4",
|
|
22
|
-
"resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",
|
|
23
|
-
"integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==",
|
|
24
190
|
"requires": {
|
|
25
191
|
"string-width": "^4.2.0",
|
|
26
192
|
"strip-ansi": "^6.0.0",
|
|
@@ -29,46 +195,30 @@
|
|
|
29
195
|
},
|
|
30
196
|
"color-convert": {
|
|
31
197
|
"version": "2.0.1",
|
|
32
|
-
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
|
33
|
-
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
|
34
198
|
"requires": {
|
|
35
199
|
"color-name": "~1.1.4"
|
|
36
200
|
}
|
|
37
201
|
},
|
|
38
202
|
"color-name": {
|
|
39
|
-
"version": "1.1.4"
|
|
40
|
-
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
|
41
|
-
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
|
|
203
|
+
"version": "1.1.4"
|
|
42
204
|
},
|
|
43
205
|
"emoji-regex": {
|
|
44
|
-
"version": "8.0.0"
|
|
45
|
-
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
|
46
|
-
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="
|
|
206
|
+
"version": "8.0.0"
|
|
47
207
|
},
|
|
48
208
|
"escalade": {
|
|
49
|
-
"version": "3.1.1"
|
|
50
|
-
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
|
|
51
|
-
"integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw=="
|
|
209
|
+
"version": "3.1.1"
|
|
52
210
|
},
|
|
53
211
|
"get-caller-file": {
|
|
54
|
-
"version": "2.0.5"
|
|
55
|
-
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
|
56
|
-
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="
|
|
212
|
+
"version": "2.0.5"
|
|
57
213
|
},
|
|
58
214
|
"is-fullwidth-code-point": {
|
|
59
|
-
"version": "3.0.0"
|
|
60
|
-
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
|
61
|
-
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg=="
|
|
215
|
+
"version": "3.0.0"
|
|
62
216
|
},
|
|
63
217
|
"require-directory": {
|
|
64
|
-
"version": "2.1.1"
|
|
65
|
-
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
|
66
|
-
"integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I="
|
|
218
|
+
"version": "2.1.1"
|
|
67
219
|
},
|
|
68
220
|
"string-width": {
|
|
69
221
|
"version": "4.2.2",
|
|
70
|
-
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz",
|
|
71
|
-
"integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==",
|
|
72
222
|
"requires": {
|
|
73
223
|
"emoji-regex": "^8.0.0",
|
|
74
224
|
"is-fullwidth-code-point": "^3.0.0",
|
|
@@ -77,16 +227,12 @@
|
|
|
77
227
|
},
|
|
78
228
|
"strip-ansi": {
|
|
79
229
|
"version": "6.0.0",
|
|
80
|
-
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",
|
|
81
|
-
"integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==",
|
|
82
230
|
"requires": {
|
|
83
231
|
"ansi-regex": "^5.0.0"
|
|
84
232
|
}
|
|
85
233
|
},
|
|
86
234
|
"wrap-ansi": {
|
|
87
235
|
"version": "7.0.0",
|
|
88
|
-
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
|
89
|
-
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
|
|
90
236
|
"requires": {
|
|
91
237
|
"ansi-styles": "^4.0.0",
|
|
92
238
|
"string-width": "^4.1.0",
|
|
@@ -95,18 +241,13 @@
|
|
|
95
241
|
},
|
|
96
242
|
"ws": {
|
|
97
243
|
"version": "7.5.3",
|
|
98
|
-
"
|
|
99
|
-
"integrity": "sha512-kQ/dHIzuLrS6Je9+uv81ueZomEwH0qVYstcAQ4/Z93K8zeko9gtAbttJWzoC5ukqXY1PpoouV3+VSOqEAFt5wg=="
|
|
244
|
+
"requires": {}
|
|
100
245
|
},
|
|
101
246
|
"y18n": {
|
|
102
|
-
"version": "5.0.8"
|
|
103
|
-
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
|
104
|
-
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="
|
|
247
|
+
"version": "5.0.8"
|
|
105
248
|
},
|
|
106
249
|
"yargs": {
|
|
107
250
|
"version": "16.2.0",
|
|
108
|
-
"resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz",
|
|
109
|
-
"integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==",
|
|
110
251
|
"requires": {
|
|
111
252
|
"cliui": "^7.0.2",
|
|
112
253
|
"escalade": "^3.1.1",
|
|
@@ -118,9 +259,7 @@
|
|
|
118
259
|
}
|
|
119
260
|
},
|
|
120
261
|
"yargs-parser": {
|
|
121
|
-
"version": "20.2.7"
|
|
122
|
-
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.7.tgz",
|
|
123
|
-
"integrity": "sha512-FiNkvbeHzB/syOjIUxFDCnhSfzAL8R5vs40MgLFBorXACCOAEaWu0gRZl14vG8MR9AOJIZbmkjhusqBYZ3HTHw=="
|
|
262
|
+
"version": "20.2.7"
|
|
124
263
|
}
|
|
125
264
|
}
|
|
126
265
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
1
2
|
const WebSocket = require('ws');
|
|
2
3
|
|
|
3
4
|
const clients = {};
|
|
@@ -5,7 +6,7 @@ const clients = {};
|
|
|
5
6
|
const wss = new WebSocket.Server({ port: 8000 });
|
|
6
7
|
|
|
7
8
|
wss.on('connection', (ws, req) => {
|
|
8
|
-
const id = req.url.replace('/', '')
|
|
9
|
+
const id = req.url.replace('/', '');
|
|
9
10
|
console.log(`New Connection from ${id}`);
|
|
10
11
|
|
|
11
12
|
clients[id] = ws;
|
|
@@ -15,12 +16,10 @@ wss.on('connection', (ws, req) => {
|
|
|
15
16
|
let peerWs = clients[peerId];
|
|
16
17
|
|
|
17
18
|
console.log(`Message from ${id} to ${peerId} : ${buffer}`);
|
|
18
|
-
if (!peerWs)
|
|
19
|
-
return console.error(`Can not find peer with ID ${peerId}`);
|
|
19
|
+
if (!peerWs) return console.error(`Can not find peer with ID ${peerId}`);
|
|
20
20
|
|
|
21
21
|
msg.id = id;
|
|
22
22
|
peerWs.send(JSON.stringify(msg));
|
|
23
|
-
|
|
24
23
|
});
|
|
25
24
|
|
|
26
25
|
ws.on('close', () => {
|
|
@@ -28,4 +27,3 @@ wss.on('connection', (ws, req) => {
|
|
|
28
27
|
delete clients[id];
|
|
29
28
|
});
|
|
30
29
|
});
|
|
31
|
-
|