@device-portal/react 0.0.4 → 0.0.5

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.
@@ -1,367 +0,0 @@
1
- import { createClass as _createClass, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime, classCallCheck as _classCallCheck, defineProperty as _defineProperty } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import { delay } from '../delay.js';
3
- import { settings } from '../settings.js';
4
-
5
- var Peer = /*#__PURE__*/function () {
6
- function Peer(room) {
7
- var _options$sendLastValu, _options$websocketSig, _options$iceServers;
8
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
9
- _classCallCheck(this, Peer);
10
- _defineProperty(this, "isDestroyed", false);
11
- _defineProperty(this, "connection", null);
12
- _defineProperty(this, "channel", null);
13
- _defineProperty(this, "value", null);
14
- _defineProperty(this, "socket", null);
15
- _defineProperty(this, "candidatesQueue", []);
16
- _defineProperty(this, "peerId", null);
17
- this.room = room;
18
- this.onMessage = options.onMessage;
19
- this.sendLastValueOnConnectAndReconnect = (_options$sendLastValu = options.sendLastValueOnConnectAndReconnect) !== null && _options$sendLastValu !== void 0 ? _options$sendLastValu : true;
20
- this.websocketSignalingServer = "".concat(((_options$websocketSig = options.websocketSignalingServer) !== null && _options$websocketSig !== void 0 ? _options$websocketSig : settings.defaultWebsocketSignalingServer).replace(/\/+$/, ''), "/v0/");
21
- this.iceServers = (_options$iceServers = options.iceServers) !== null && _options$iceServers !== void 0 ? _options$iceServers : settings.iceServers;
22
- this.run();
23
- }
24
- return _createClass(Peer, [{
25
- key: "run",
26
- value: function () {
27
- var _run = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
28
- return _regeneratorRuntime().wrap(function _callee$(_context) {
29
- while (1) switch (_context.prev = _context.next) {
30
- case 0:
31
- _context.prev = 0;
32
- _context.next = 3;
33
- return this.connect();
34
- case 3:
35
- _context.next = 8;
36
- break;
37
- case 5:
38
- _context.prev = 5;
39
- _context.t0 = _context["catch"](0);
40
- queueMicrotask(function () {
41
- throw _context.t0;
42
- });
43
- case 8:
44
- case "end":
45
- return _context.stop();
46
- }
47
- }, _callee, this, [[0, 5]]);
48
- }));
49
- function run() {
50
- return _run.apply(this, arguments);
51
- }
52
- return run;
53
- }()
54
- }, {
55
- key: "connect",
56
- value: function connect() {
57
- var _this = this;
58
- return new Promise(function (resolve, reject) {
59
- if (_this.isDestroyed) {
60
- return reject(new Error('Peer is destroyed'));
61
- }
62
- _this.socket = new WebSocket(_this.websocketSignalingServer);
63
- _this.socket.onopen = function () {
64
- var _this$socket;
65
- console.log("[Peer] WebSocket opened for room: ".concat(_this.room));
66
- (_this$socket = _this.socket) === null || _this$socket === void 0 || _this$socket.send(JSON.stringify({
67
- type: 'join-room',
68
- room: _this.room
69
- }));
70
- _this.initializeConnectionAndChannel();
71
- _this.onConnected();
72
- resolve();
73
- };
74
- _this.socket.onmessage = function (event) {
75
- var _message$data, _message$data2;
76
- var message = JSON.parse(event.data);
77
- console.log("[Peer] Received signaling message: ".concat(message.type));
78
- switch (message.type) {
79
- case 'identity':
80
- _this.peerId = message.data.peerId;
81
- console.log("[Peer] My peer ID is: ".concat(_this.peerId));
82
- break;
83
- case 'peer-joined':
84
- if ((_message$data = message.data) !== null && _message$data !== void 0 && _message$data.peerId) {
85
- _this.handlePeerJoined(message.data.peerId);
86
- }
87
- break;
88
- case 'peer-left':
89
- if ((_message$data2 = message.data) !== null && _message$data2 !== void 0 && _message$data2.peerId) {
90
- _this.handlePeerLeft(message.data.peerId);
91
- }
92
- break;
93
- case 'offer':
94
- _this.handleOffer(message.data, message.from);
95
- break;
96
- case 'answer':
97
- _this.handleAnswer(message.data, message.from);
98
- break;
99
- case 'ice-candidate':
100
- _this.handleIceCandidate(message.data, message.from);
101
- break;
102
- }
103
- };
104
- _this.socket.onclose = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
105
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
106
- while (1) switch (_context2.prev = _context2.next) {
107
- case 0:
108
- console.log('[Peer] WebSocket closed');
109
- _this.socket = null;
110
- if (_this.isDestroyed) {
111
- _context2.next = 8;
112
- break;
113
- }
114
- console.log('[Peer] Attempting reconnect in 1s...');
115
- _context2.next = 6;
116
- return delay(1000);
117
- case 6:
118
- _context2.next = 8;
119
- return _this.run();
120
- case 8:
121
- case "end":
122
- return _context2.stop();
123
- }
124
- }, _callee2);
125
- }));
126
- _this.socket.onerror = function (error) {
127
- console.error('WebSocket error:', error);
128
- reject(error);
129
- };
130
- });
131
- }
132
- }, {
133
- key: "handleIceCandidate",
134
- value: function () {
135
- var _handleIceCandidate = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(candidate, fromPeerId) {
136
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
137
- while (1) switch (_context3.prev = _context3.next) {
138
- case 0:
139
- if (this.connection) {
140
- _context3.next = 2;
141
- break;
142
- }
143
- return _context3.abrupt("return");
144
- case 2:
145
- if (!this.connection.remoteDescription) {
146
- _context3.next = 14;
147
- break;
148
- }
149
- _context3.prev = 3;
150
- console.log('[Peer] Adding received ICE candidate');
151
- _context3.next = 7;
152
- return this.connection.addIceCandidate(new RTCIceCandidate(candidate));
153
- case 7:
154
- _context3.next = 12;
155
- break;
156
- case 9:
157
- _context3.prev = 9;
158
- _context3.t0 = _context3["catch"](3);
159
- console.error('[Peer] Error adding ice candidate:', _context3.t0);
160
- case 12:
161
- _context3.next = 16;
162
- break;
163
- case 14:
164
- console.log('[Peer] Queuing ICE candidate (remote description not set)');
165
- this.candidatesQueue.push(candidate);
166
- case 16:
167
- case "end":
168
- return _context3.stop();
169
- }
170
- }, _callee3, this, [[3, 9]]);
171
- }));
172
- function handleIceCandidate(_x, _x2) {
173
- return _handleIceCandidate.apply(this, arguments);
174
- }
175
- return handleIceCandidate;
176
- }()
177
- }, {
178
- key: "processCandidatesQueue",
179
- value: function () {
180
- var _processCandidatesQueue = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
181
- var candidate;
182
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
183
- while (1) switch (_context4.prev = _context4.next) {
184
- case 0:
185
- if (this.connection) {
186
- _context4.next = 2;
187
- break;
188
- }
189
- return _context4.abrupt("return");
190
- case 2:
191
- if (this.candidatesQueue.length > 0) {
192
- console.log("[Peer] Processing ".concat(this.candidatesQueue.length, " queued ICE candidates"));
193
- }
194
- case 3:
195
- if (!(this.candidatesQueue.length > 0)) {
196
- _context4.next = 15;
197
- break;
198
- }
199
- candidate = this.candidatesQueue.shift();
200
- _context4.prev = 5;
201
- _context4.next = 8;
202
- return this.connection.addIceCandidate(new RTCIceCandidate(candidate));
203
- case 8:
204
- _context4.next = 13;
205
- break;
206
- case 10:
207
- _context4.prev = 10;
208
- _context4.t0 = _context4["catch"](5);
209
- console.error('[Peer] Error adding queued ice candidate:', _context4.t0);
210
- case 13:
211
- _context4.next = 3;
212
- break;
213
- case 15:
214
- case "end":
215
- return _context4.stop();
216
- }
217
- }, _callee4, this, [[5, 10]]);
218
- }));
219
- function processCandidatesQueue() {
220
- return _processCandidatesQueue.apply(this, arguments);
221
- }
222
- return processCandidatesQueue;
223
- }()
224
- }, {
225
- key: "close",
226
- value: function close() {
227
- var _this$connection, _this$channel, _this$socket2;
228
- (_this$connection = this.connection) === null || _this$connection === void 0 || _this$connection.close();
229
- this.connection = null;
230
- (_this$channel = this.channel) === null || _this$channel === void 0 || _this$channel.close();
231
- this.channel = null;
232
- (_this$socket2 = this.socket) === null || _this$socket2 === void 0 || _this$socket2.close();
233
- this.socket = null;
234
- }
235
- }, {
236
- key: "destroy",
237
- value: function destroy() {
238
- this.isDestroyed = true;
239
- this.close();
240
- }
241
- }, {
242
- key: "sendMessage",
243
- value: function sendMessage(type, data, to) {
244
- var _this$socket3;
245
- if (((_this$socket3 = this.socket) === null || _this$socket3 === void 0 ? void 0 : _this$socket3.readyState) === WebSocket.OPEN) {
246
- console.log("[Peer] Sending signaling message: ".concat(type).concat(to ? " to ".concat(to) : ''));
247
- this.socket.send(JSON.stringify({
248
- type: type,
249
- room: this.room,
250
- data: data,
251
- to: to
252
- }));
253
- } else {
254
- console.warn("[Peer] Cannot send message ".concat(type, ", WebSocket not open"));
255
- }
256
- }
257
- }, {
258
- key: "setAndShareLocalDescription",
259
- value: function () {
260
- var _setAndShareLocalDescription = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(description, toPeerId) {
261
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
262
- while (1) switch (_context5.prev = _context5.next) {
263
- case 0:
264
- if (this.connection) {
265
- _context5.next = 2;
266
- break;
267
- }
268
- throw new Error('Connection is not initialized');
269
- case 2:
270
- console.log("[Peer] Setting local description (".concat(description.type, ")"));
271
- _context5.next = 5;
272
- return this.connection.setLocalDescription(description);
273
- case 5:
274
- this.sendMessage(description.type, description, toPeerId);
275
- case 6:
276
- case "end":
277
- return _context5.stop();
278
- }
279
- }, _callee5, this);
280
- }));
281
- function setAndShareLocalDescription(_x3, _x4) {
282
- return _setAndShareLocalDescription.apply(this, arguments);
283
- }
284
- return setAndShareLocalDescription;
285
- }()
286
- }, {
287
- key: "shareNewIceCandidate",
288
- value: function shareNewIceCandidate(event, toPeerId) {
289
- if (event.candidate) {
290
- console.log('[Peer] Generated new ICE candidate');
291
- this.sendMessage('ice-candidate', event.candidate.toJSON(), toPeerId);
292
- }
293
- }
294
- }, {
295
- key: "send",
296
- value: function send(value) {
297
- var _this$channel2;
298
- if (((_this$channel2 = this.channel) === null || _this$channel2 === void 0 ? void 0 : _this$channel2.readyState) === 'open') {
299
- this.channel.send(value);
300
- }
301
- this.value = {
302
- value: value
303
- };
304
- }
305
- }, {
306
- key: "initializeConnectionAndChannel",
307
- value: function initializeConnectionAndChannel() {
308
- var _this2 = this;
309
- if (this.connection) {
310
- return;
311
- }
312
- this.candidatesQueue = [];
313
- this.connection = new RTCPeerConnection({
314
- iceServers: this.iceServers
315
- });
316
- this.connection.onicecandidate = this.shareNewIceCandidate.bind(this);
317
- this.connection.oniceconnectionstatechange = function () {
318
- var _this2$connection;
319
- console.log("ICE connection state: ".concat((_this2$connection = _this2.connection) === null || _this2$connection === void 0 ? void 0 : _this2$connection.iceConnectionState));
320
- };
321
- this.connection.onconnectionstatechange = function () {
322
- var _this2$connection2;
323
- console.log("Connection state: ".concat((_this2$connection2 = _this2.connection) === null || _this2$connection2 === void 0 ? void 0 : _this2$connection2.connectionState));
324
- };
325
- if (this.role === 'initiator') {
326
- console.log('[Peer] Creating data channel');
327
- this.channel = this.connection.createDataChannel(settings.channel.label);
328
- this.channel.onopen = function () {
329
- console.log('[Peer] Data channel opened');
330
- if (_this2.value && _this2.sendLastValueOnConnectAndReconnect) {
331
- var _this2$channel;
332
- (_this2$channel = _this2.channel) === null || _this2$channel === void 0 || _this2$channel.send(_this2.value.value);
333
- }
334
- };
335
- this.channel.onmessage = function (event) {
336
- console.log('[Peer] Data channel message received');
337
- if (_this2.peerId) {
338
- var _this2$onMessage;
339
- (_this2$onMessage = _this2.onMessage) === null || _this2$onMessage === void 0 || _this2$onMessage.call(_this2, event.data, _this2.peerId);
340
- }
341
- };
342
- } else {
343
- this.connection.ondatachannel = function (event) {
344
- console.log('[Peer] Data channel received (responder)');
345
- _this2.channel = event.channel;
346
- _this2.channel.onopen = function () {
347
- console.log('[Peer] Data channel opened');
348
- if (_this2.value && _this2.sendLastValueOnConnectAndReconnect) {
349
- var _this2$channel2;
350
- (_this2$channel2 = _this2.channel) === null || _this2$channel2 === void 0 || _this2$channel2.send(_this2.value.value);
351
- }
352
- };
353
- _this2.channel.onmessage = function (event) {
354
- console.log('[Peer] Data channel message received');
355
- if (_this2.peerId) {
356
- var _this2$onMessage2;
357
- (_this2$onMessage2 = _this2.onMessage) === null || _this2$onMessage2 === void 0 || _this2$onMessage2.call(_this2, event.data, _this2.peerId);
358
- }
359
- };
360
- };
361
- }
362
- }
363
- }]);
364
- }();
365
-
366
- export { Peer };
367
- //# sourceMappingURL=Peer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Peer.js","sources":["../../src/webrtc/Peer.ts"],"sourcesContent":["import { delay } from '../delay'\nimport { settings } from '../settings'\nimport { PeerId } from './PeerId'\n\nexport abstract class Peer {\n\tprotected isDestroyed = false\n\tprotected connection: RTCPeerConnection | null = null\n\tprotected channel: RTCDataChannel | null = null\n\tprotected abstract role: 'initiator' | 'responder'\n\tprotected value: { value: string } | null = null\n\tprotected readonly onMessage:\n\t\t| ((value: string, peerId: PeerId) => void)\n\t\t| undefined\n\tprotected readonly sendLastValueOnConnectAndReconnect: boolean\n\tprotected readonly websocketSignalingServer: string\n\tprotected readonly iceServers: Array<RTCIceServer>\n\tprotected socket: WebSocket | null = null\n\tprotected candidatesQueue: RTCIceCandidateInit[] = []\n\tprotected peerId: PeerId | null = null\n\n\tconstructor(\n\t\tprotected readonly room: string,\n\t\toptions: {\n\t\t\twebsocketSignalingServer?: string\n\t\t\tonMessage?: (value: string, peerId: PeerId) => void\n\t\t\tsendLastValueOnConnectAndReconnect?: boolean\n\t\t\ticeServers?: Array<RTCIceServer>\n\t\t} = {},\n\t) {\n\t\tthis.onMessage = options.onMessage\n\t\tthis.sendLastValueOnConnectAndReconnect =\n\t\t\toptions.sendLastValueOnConnectAndReconnect ?? true\n\t\tthis.websocketSignalingServer = `${(\n\t\t\toptions.websocketSignalingServer ??\n\t\t\tsettings.defaultWebsocketSignalingServer\n\t\t).replace(/\\/+$/, '')}/v0/`\n\t\tthis.iceServers = options.iceServers ?? settings.iceServers\n\t\tthis.run()\n\t}\n\n\tprotected async run() {\n\t\ttry {\n\t\t\tawait this.connect()\n\t\t} catch (error) {\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tthrow error\n\t\t\t})\n\t\t}\n\t}\n\n\tprotected connect(): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (this.isDestroyed) {\n\t\t\t\treturn reject(new Error('Peer is destroyed'))\n\t\t\t}\n\n\t\t\tthis.socket = new WebSocket(this.websocketSignalingServer)\n\n\t\t\tthis.socket.onopen = () => {\n\t\t\t\tconsole.log(`[Peer] WebSocket opened for room: ${this.room}`)\n\t\t\t\tthis.socket?.send(\n\t\t\t\t\tJSON.stringify({ type: 'join-room', room: this.room }),\n\t\t\t\t)\n\t\t\t\tthis.initializeConnectionAndChannel()\n\t\t\t\tthis.onConnected()\n\t\t\t\tresolve()\n\t\t\t}\n\n\t\t\tthis.socket.onmessage = (event) => {\n\t\t\t\tconst message = JSON.parse(event.data)\n\t\t\t\tconsole.log(`[Peer] Received signaling message: ${message.type}`)\n\t\t\t\tswitch (message.type) {\n\t\t\t\t\tcase 'identity':\n\t\t\t\t\t\tthis.peerId = message.data.peerId\n\t\t\t\t\t\tconsole.log(`[Peer] My peer ID is: ${this.peerId}`)\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'peer-joined':\n\t\t\t\t\t\tif (message.data?.peerId) {\n\t\t\t\t\t\t\tthis.handlePeerJoined(message.data.peerId)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'peer-left':\n\t\t\t\t\t\tif (message.data?.peerId) {\n\t\t\t\t\t\t\tthis.handlePeerLeft(message.data.peerId)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'offer':\n\t\t\t\t\t\tthis.handleOffer(message.data, message.from)\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'answer':\n\t\t\t\t\t\tthis.handleAnswer(message.data, message.from)\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'ice-candidate':\n\t\t\t\t\t\tthis.handleIceCandidate(message.data, message.from)\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.socket.onclose = async () => {\n\t\t\t\tconsole.log('[Peer] WebSocket closed')\n\t\t\t\tthis.socket = null\n\t\t\t\tif (!this.isDestroyed) {\n\t\t\t\t\tconsole.log('[Peer] Attempting reconnect in 1s...')\n\t\t\t\t\tawait delay(1000)\n\t\t\t\t\tawait this.run() // Reconnect\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.socket.onerror = (error) => {\n\t\t\t\tconsole.error('WebSocket error:', error)\n\t\t\t\treject(error)\n\t\t\t}\n\t\t})\n\t}\n\n\tprotected abstract handleOffer(\n\t\toffer: RTCSessionDescriptionInit,\n\t\tfromPeerId: PeerId,\n\t): void\n\tprotected abstract handleAnswer(\n\t\tanswer: RTCSessionDescriptionInit,\n\t\tfromPeerId: PeerId,\n\t): void\n\tprotected abstract handlePeerJoined(peerId: PeerId): void\n\tprotected abstract handlePeerLeft(peerId: PeerId): void\n\tprotected abstract onConnected(): void\n\n\tprotected async handleIceCandidate(\n\t\tcandidate: RTCIceCandidateInit,\n\t\tfromPeerId?: PeerId,\n\t) {\n\t\tif (!this.connection) {\n\t\t\treturn\n\t\t}\n\t\tif (this.connection.remoteDescription) {\n\t\t\ttry {\n\t\t\t\tconsole.log('[Peer] Adding received ICE candidate')\n\t\t\t\tawait this.connection.addIceCandidate(new RTCIceCandidate(candidate))\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[Peer] Error adding ice candidate:', error)\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.log('[Peer] Queuing ICE candidate (remote description not set)')\n\t\t\tthis.candidatesQueue.push(candidate)\n\t\t}\n\t}\n\n\tprotected async processCandidatesQueue() {\n\t\tif (!this.connection) {\n\t\t\treturn\n\t\t}\n\t\tif (this.candidatesQueue.length > 0) {\n\t\t\tconsole.log(\n\t\t\t\t`[Peer] Processing ${this.candidatesQueue.length} queued ICE candidates`,\n\t\t\t)\n\t\t}\n\t\twhile (this.candidatesQueue.length > 0) {\n\t\t\tconst candidate = this.candidatesQueue.shift()!\n\t\t\ttry {\n\t\t\t\tawait this.connection.addIceCandidate(new RTCIceCandidate(candidate))\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[Peer] Error adding queued ice candidate:', error)\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected close() {\n\t\tthis.connection?.close()\n\t\tthis.connection = null\n\t\tthis.channel?.close()\n\t\tthis.channel = null\n\t\tthis.socket?.close()\n\t\tthis.socket = null\n\t}\n\n\tpublic destroy() {\n\t\tthis.isDestroyed = true\n\t\tthis.close()\n\t}\n\n\tprotected sendMessage(type: string, data: any, to?: PeerId) {\n\t\tif (this.socket?.readyState === WebSocket.OPEN) {\n\t\t\tconsole.log(\n\t\t\t\t`[Peer] Sending signaling message: ${type}${to ? ` to ${to}` : ''}`,\n\t\t\t)\n\t\t\tthis.socket.send(JSON.stringify({ type, room: this.room, data, to }))\n\t\t} else {\n\t\t\tconsole.warn(`[Peer] Cannot send message ${type}, WebSocket not open`)\n\t\t}\n\t}\n\n\tprotected async setAndShareLocalDescription(\n\t\tdescription: RTCSessionDescriptionInit,\n\t\ttoPeerId?: PeerId,\n\t) {\n\t\tif (!this.connection) {\n\t\t\tthrow new Error('Connection is not initialized')\n\t\t}\n\t\tconsole.log(`[Peer] Setting local description (${description.type})`)\n\t\tawait this.connection.setLocalDescription(description)\n\t\tthis.sendMessage(description.type, description, toPeerId)\n\t}\n\n\tprotected shareNewIceCandidate(\n\t\tevent: RTCPeerConnectionIceEvent,\n\t\ttoPeerId?: PeerId,\n\t) {\n\t\tif (event.candidate) {\n\t\t\tconsole.log('[Peer] Generated new ICE candidate')\n\t\t\tthis.sendMessage('ice-candidate', event.candidate.toJSON(), toPeerId)\n\t\t}\n\t}\n\n\tpublic send(value: string) {\n\t\tif (this.channel?.readyState === 'open') {\n\t\t\tthis.channel.send(value)\n\t\t}\n\t\tthis.value = { value }\n\t}\n\n\tprotected initializeConnectionAndChannel() {\n\t\tif (this.connection) {\n\t\t\treturn\n\t\t}\n\t\tthis.candidatesQueue = []\n\t\tthis.connection = new RTCPeerConnection({ iceServers: this.iceServers })\n\t\tthis.connection.onicecandidate = this.shareNewIceCandidate.bind(this)\n\t\tthis.connection.oniceconnectionstatechange = () => {\n\t\t\tconsole.log(\n\t\t\t\t`ICE connection state: ${this.connection?.iceConnectionState}`,\n\t\t\t)\n\t\t}\n\t\tthis.connection.onconnectionstatechange = () => {\n\t\t\tconsole.log(`Connection state: ${this.connection?.connectionState}`)\n\t\t}\n\n\t\tif (this.role === 'initiator') {\n\t\t\tconsole.log('[Peer] Creating data channel')\n\t\t\tthis.channel = this.connection.createDataChannel(settings.channel.label)\n\t\t\tthis.channel.onopen = () => {\n\t\t\t\tconsole.log('[Peer] Data channel opened')\n\t\t\t\tif (this.value && this.sendLastValueOnConnectAndReconnect) {\n\t\t\t\t\tthis.channel?.send(this.value.value)\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.channel.onmessage = (event) => {\n\t\t\t\tconsole.log('[Peer] Data channel message received')\n\t\t\t\tif (this.peerId) {\n\t\t\t\t\tthis.onMessage?.(event.data, this.peerId)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.connection.ondatachannel = (event) => {\n\t\t\t\tconsole.log('[Peer] Data channel received (responder)')\n\t\t\t\tthis.channel = event.channel\n\t\t\t\tthis.channel.onopen = () => {\n\t\t\t\t\tconsole.log('[Peer] Data channel opened')\n\t\t\t\t\tif (this.value && this.sendLastValueOnConnectAndReconnect) {\n\t\t\t\t\t\tthis.channel?.send(this.value.value)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.channel.onmessage = (event) => {\n\t\t\t\t\tconsole.log('[Peer] Data channel message received')\n\t\t\t\t\tif (this.peerId) {\n\t\t\t\t\t\tthis.onMessage?.(event.data, this.peerId)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["Peer","room","_options$sendLastValu","_options$websocketSig","_options$iceServers","options","arguments","length","undefined","_classCallCheck","_defineProperty","onMessage","sendLastValueOnConnectAndReconnect","websocketSignalingServer","concat","settings","defaultWebsocketSignalingServer","replace","iceServers","run","_createClass","key","value","_run","_asyncToGenerator","_regeneratorRuntime","mark","_callee","wrap","_callee$","_context","prev","next","connect","t0","queueMicrotask","stop","apply","_this","Promise","resolve","reject","isDestroyed","Error","socket","WebSocket","onopen","_this$socket","console","log","send","JSON","stringify","type","initializeConnectionAndChannel","onConnected","onmessage","event","_message$data","_message$data2","message","parse","data","peerId","handlePeerJoined","handlePeerLeft","handleOffer","from","handleAnswer","handleIceCandidate","onclose","_callee2","_callee2$","_context2","delay","onerror","error","_handleIceCandidate","_callee3","candidate","fromPeerId","_callee3$","_context3","connection","abrupt","remoteDescription","addIceCandidate","RTCIceCandidate","candidatesQueue","push","_x","_x2","_processCandidatesQueue","_callee4","_callee4$","_context4","shift","processCandidatesQueue","close","_this$connection","_this$channel","_this$socket2","channel","destroy","sendMessage","to","_this$socket3","readyState","OPEN","warn","_setAndShareLocalDescription","_callee5","description","toPeerId","_callee5$","_context5","setLocalDescription","setAndShareLocalDescription","_x3","_x4","shareNewIceCandidate","toJSON","_this$channel2","_this2","RTCPeerConnection","onicecandidate","bind","oniceconnectionstatechange","_this2$connection","iceConnectionState","onconnectionstatechange","_this2$connection2","connectionState","role","createDataChannel","label","_this2$channel","_this2$onMessage","call","ondatachannel","_this2$channel2","_this2$onMessage2"],"mappings":";;;;AAIA,IAAsBA,IAAI,gBAAA,YAAA;EAgBzB,SAAAA,IAAAA,CACoBC,IAAY,EAO9B;AAAA,IAAA,IAAAC,qBAAA,EAAAC,qBAAA,EAAAC,mBAAA;AAAA,IAAA,IANDC,OAKC,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE;AAAAG,IAAAA,eAAA,OAAAT,IAAA,CAAA;AAAAU,IAAAA,eAAA,sBAtBiB,KAAK,CAAA;AAAAA,IAAAA,eAAA,qBACoB,IAAI,CAAA;AAAAA,IAAAA,eAAA,kBACV,IA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,eAAdA,gBAAA,CAAAC,IAAA,CAAAf,MAAI,EAAalE,KAAK,CAACK,IAAI,EAAE6D,MAAI,CAAC5D,MAAM,CAAC;AAC1C;SACA;AACF,OAAC,MAAM;AACN,QAAA,IAAI,CAACoB,UAAU,CAACwD,aAAa,GAAG,UAAClF,KAAK,EAAK;AAC1CT,UAAAA,OAAO,CAACC,GAAG,CAAC,0CAA0C,CAAC;AACvD0E,UAAAA,MAAI,CAACrB,OAAO,GAAG7C,KAAK,CAAC6C,OAAO;AAC5BqB,UAAAA,MAAI,CAACrB,OAAO,CAACxD,MAAM,GAAG,YAAM;AAC3BE,YAAAA,OAAO,CAACC,GAAG,CAAC,4BAA4B,CAAC;AACzC,YAAA,IAAI0E,MAAI,CAACrG,KAAK,IAAIqG,MAAI,CAAC/G,kCAAkC,EAAE;AAAA,cAAA,IAAAgI,eAAA;AAC1D,cAAA,CAAAA,eAAA,GAAAjB,MAAI,CAACrB,OAAO,cAAAsC,eAAA,KAAA,MAAA,IAAZA,eAAA,CAAc1F,IAAI,CAACyE,MAAI,CAACrG,KAAK,CAACA,KAAK,CAAC;AACrC;WACA;AACDqG,UAAAA,MAAI,CAACrB,OAAO,CAAC9C,SAAS,GAAG,UAACC,KAAK,EAAK;AACnCT,YAAAA,OAAO,CAACC,GAAG,CAAC,sCAAsC,CAAC;YACnD,IAAI0E,MAAI,CAAC5D,MAAM,EAAE;AAAA,cAAA,IAAA8E,iBAAA;cAChB,CAAAA,iBAAA,GAAAlB,MAAI,CAAChH,SAAS,MAAAkI,IAAAA,IAAAA,iBAAA,eAAdA,iBAAA,CAAAH,IAAA,CAAAf,MAAI,EAAalE,KAAK,CAACK,IAAI,EAAE6D,MAAI,CAAC5D,MAAM,CAAC;AAC1C;WACA;SACD;AACF;AACD;AAAC,GAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
@@ -1,133 +0,0 @@
1
- import { inherits as _inherits, createClass as _createClass, superPropGet as _superPropGet, asyncToGenerator as _asyncToGenerator, classCallCheck as _classCallCheck, callSuper as _callSuper, defineProperty as _defineProperty, regeneratorRuntime as _regeneratorRuntime } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import { Peer } from './Peer.js';
3
-
4
- var Responder = /*#__PURE__*/function (_Peer) {
5
- function Responder() {
6
- var _this;
7
- _classCallCheck(this, Responder);
8
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
9
- args[_key] = arguments[_key];
10
- }
11
- _this = _callSuper(this, Responder, [].concat(args));
12
- _defineProperty(_this, "role", 'responder');
13
- _defineProperty(_this, "reconnectTimeout", null);
14
- return _this;
15
- }
16
- _inherits(Responder, _Peer);
17
- return _createClass(Responder, [{
18
- key: "onConnected",
19
- value: function onConnected() {
20
- // Responder waits for an offer
21
- this.startReconnectionTimer();
22
- }
23
- }, {
24
- key: "handlePeerJoined",
25
- value: function handlePeerJoined(peerId) {
26
- // Responder does not need to do anything when a peer joins, it waits for an offer
27
- }
28
- }, {
29
- key: "handlePeerLeft",
30
- value: function handlePeerLeft(peerId) {
31
- // Responder logic for when a peer leaves
32
- console.log("[Responder] Peer ".concat(peerId, " left"));
33
- this.startReconnectionTimer();
34
- }
35
- }, {
36
- key: "startReconnectionTimer",
37
- value: function startReconnectionTimer() {
38
- var _this2 = this;
39
- if (this.reconnectTimeout || this.isDestroyed) {
40
- return;
41
- }
42
- console.log('[Responder] Starting reconnection timer...');
43
- this.reconnectTimeout = setTimeout(function () {
44
- _this2.reconnectTimeout = null;
45
- if (_this2.isDestroyed) {
46
- return;
47
- }
48
- if (!_this2.connection || _this2.connection.iceConnectionState === 'failed' || _this2.connection.iceConnectionState === 'disconnected' || _this2.connection.iceConnectionState === 'closed') {
49
- var _this2$socket;
50
- console.log('[Responder] Attempting to re-join room for reconnection...');
51
- (_this2$socket = _this2.socket) === null || _this2$socket === void 0 || _this2$socket.send(JSON.stringify({
52
- type: 'join-room',
53
- room: _this2.room
54
- }));
55
- _this2.startReconnectionTimer(); // Schedule next attempt if it still fails
56
- }
57
- }, 3000);
58
- }
59
- }, {
60
- key: "stopReconnectionTimer",
61
- value: function stopReconnectionTimer() {
62
- if (this.reconnectTimeout) {
63
- clearTimeout(this.reconnectTimeout);
64
- this.reconnectTimeout = null;
65
- }
66
- }
67
- }, {
68
- key: "handleOffer",
69
- value: function () {
70
- var _handleOffer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(offer, fromPeerId) {
71
- var _this3 = this;
72
- var answer;
73
- return _regeneratorRuntime().wrap(function _callee$(_context) {
74
- while (1) switch (_context.prev = _context.next) {
75
- case 0:
76
- console.log("[Responder] Handling offer from ".concat(fromPeerId));
77
- this.stopReconnectionTimer();
78
- this.initializeConnectionAndChannel();
79
- if (this.connection) {
80
- _context.next = 5;
81
- break;
82
- }
83
- throw new Error('Connection is not initialized');
84
- case 5:
85
- this.connection.oniceconnectionstatechange = function () {
86
- var _this3$connection, _this3$connection2, _this3$connection3, _this3$connection4, _this3$connection5, _this3$connection6;
87
- console.log("[Responder] ICE connection state: ".concat((_this3$connection = _this3.connection) === null || _this3$connection === void 0 ? void 0 : _this3$connection.iceConnectionState));
88
- if (((_this3$connection2 = _this3.connection) === null || _this3$connection2 === void 0 ? void 0 : _this3$connection2.iceConnectionState) === 'failed' || ((_this3$connection3 = _this3.connection) === null || _this3$connection3 === void 0 ? void 0 : _this3$connection3.iceConnectionState) === 'disconnected' || ((_this3$connection4 = _this3.connection) === null || _this3$connection4 === void 0 ? void 0 : _this3$connection4.iceConnectionState) === 'closed') {
89
- _this3.startReconnectionTimer();
90
- } else if (((_this3$connection5 = _this3.connection) === null || _this3$connection5 === void 0 ? void 0 : _this3$connection5.iceConnectionState) === 'connected' || ((_this3$connection6 = _this3.connection) === null || _this3$connection6 === void 0 ? void 0 : _this3$connection6.iceConnectionState) === 'completed') {
91
- _this3.stopReconnectionTimer();
92
- }
93
- };
94
- _context.next = 8;
95
- return this.connection.setRemoteDescription(offer);
96
- case 8:
97
- _context.next = 10;
98
- return this.processCandidatesQueue();
99
- case 10:
100
- console.log('[Responder] Creating answer');
101
- _context.next = 13;
102
- return this.connection.createAnswer();
103
- case 13:
104
- answer = _context.sent;
105
- _context.next = 16;
106
- return this.setAndShareLocalDescription(answer, fromPeerId);
107
- case 16:
108
- case "end":
109
- return _context.stop();
110
- }
111
- }, _callee, this);
112
- }));
113
- function handleOffer(_x, _x2) {
114
- return _handleOffer.apply(this, arguments);
115
- }
116
- return handleOffer;
117
- }()
118
- }, {
119
- key: "destroy",
120
- value: function destroy() {
121
- this.stopReconnectionTimer();
122
- _superPropGet(Responder, "destroy", this)([]);
123
- }
124
- }, {
125
- key: "handleAnswer",
126
- value: function handleAnswer(answer, fromPeerId) {
127
- // Responder does not handle answers
128
- }
129
- }]);
130
- }(Peer);
131
-
132
- export { Responder };
133
- //# sourceMappingURL=Responder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Responder.js","sources":["../../src/webrtc/Responder.ts"],"sourcesContent":["import { Peer } from './Peer'\nimport { PeerId } from './PeerId'\n\nexport class Responder extends Peer {\n\tprotected role = 'responder' as const\n\tprivate reconnectTimeout: ReturnType<typeof setTimeout> | null = null\n\n\tprotected onConnected(): void {\n\t\t// Responder waits for an offer\n\t\tthis.startReconnectionTimer()\n\t}\n\n\tprotected handlePeerJoined(peerId: PeerId) {\n\t\t// Responder does not need to do anything when a peer joins, it waits for an offer\n\t}\n\n\tprotected handlePeerLeft(peerId: PeerId) {\n\t\t// Responder logic for when a peer leaves\n\t\tconsole.log(`[Responder] Peer ${peerId} left`)\n\t\tthis.startReconnectionTimer()\n\t}\n\n\tprivate startReconnectionTimer() {\n\t\tif (this.reconnectTimeout || this.isDestroyed) {\n\t\t\treturn\n\t\t}\n\t\tconsole.log('[Responder] Starting reconnection timer...')\n\t\tthis.reconnectTimeout = setTimeout(() => {\n\t\t\tthis.reconnectTimeout = null\n\t\t\tif (this.isDestroyed) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!this.connection ||\n\t\t\t\tthis.connection.iceConnectionState === 'failed' ||\n\t\t\t\tthis.connection.iceConnectionState === 'disconnected' ||\n\t\t\t\tthis.connection.iceConnectionState === 'closed'\n\t\t\t) {\n\t\t\t\tconsole.log(\n\t\t\t\t\t'[Responder] Attempting to re-join room for reconnection...',\n\t\t\t\t)\n\t\t\t\tthis.socket?.send(\n\t\t\t\t\tJSON.stringify({ type: 'join-room', room: this.room }),\n\t\t\t\t)\n\t\t\t\tthis.startReconnectionTimer() // Schedule next attempt if it still fails\n\t\t\t}\n\t\t}, 3000)\n\t}\n\n\tprivate stopReconnectionTimer() {\n\t\tif (this.reconnectTimeout) {\n\t\t\tclearTimeout(this.reconnectTimeout)\n\t\t\tthis.reconnectTimeout = null\n\t\t}\n\t}\n\n\tprotected async handleOffer(\n\t\toffer: RTCSessionDescriptionInit,\n\t\tfromPeerId: PeerId,\n\t) {\n\t\tconsole.log(`[Responder] Handling offer from ${fromPeerId}`)\n\t\tthis.stopReconnectionTimer()\n\t\tthis.initializeConnectionAndChannel()\n\t\tif (!this.connection) {\n\t\t\tthrow new Error('Connection is not initialized')\n\t\t}\n\n\t\tthis.connection.oniceconnectionstatechange = () => {\n\t\t\tconsole.log(\n\t\t\t\t`[Responder] ICE connection state: ${this.connection?.iceConnectionState}`,\n\t\t\t)\n\t\t\tif (\n\t\t\t\tthis.connection?.iceConnectionState === 'failed' ||\n\t\t\t\tthis.connection?.iceConnectionState === 'disconnected' ||\n\t\t\t\tthis.connection?.iceConnectionState === 'closed'\n\t\t\t) {\n\t\t\t\tthis.startReconnectionTimer()\n\t\t\t} else if (\n\t\t\t\tthis.connection?.iceConnectionState === 'connected' ||\n\t\t\t\tthis.connection?.iceConnectionState === 'completed'\n\t\t\t) {\n\t\t\t\tthis.stopReconnectionTimer()\n\t\t\t}\n\t\t}\n\n\t\tawait this.connection.setRemoteDescription(offer)\n\t\tawait this.processCandidatesQueue()\n\t\tconsole.log('[Responder] Creating answer')\n\t\tconst answer = await this.connection.createAnswer()\n\t\tawait this.setAndShareLocalDescription(answer, fromPeerId)\n\t}\n\n\tpublic destroy() {\n\t\tthis.stopReconnectionTimer()\n\t\tsuper.destroy()\n\t}\n\n\tprotected handleAnswer(\n\t\tanswer: RTCSessionDescriptionInit,\n\t\tfromPeerId: PeerId,\n\t): void {\n\t\t// Responder does not handle answers\n\t}\n}\n"],"names":["Responder","_Peer","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","concat","_defineProperty","_inherits","_createClass","key","value","onConnected","startReconnectionTimer","handlePeerJoined","peerId","handlePeerLeft","console","log","_this2","reconnectTimeout","isDestroyed","setTimeout","connection","iceConnectionState","_this2$socket","socket","send","JSON","stringify","type","room","stopReconnectionTimer","clearTimeout","_handleOffer","_asyncToGenerator","_regeneratorRuntime","mark","_callee","offer","fromPeerId","_this3","answer","wrap","_callee$","_context","prev","next","initializeConnectionAndChannel","Error","oniceconnectionstatechange","_this3$connection","_this3$connection2","_this3$connection3","_this3$connection4","_this3$connection5","_this3$connection6","setRemoteDescription","processCandidatesQueue","createAnswer","sent","setAndShareLocalDescription","stop","handleOffer","_x","_x2","apply","destroy","_superPropGet","handleAnswer","Peer"],"mappings":";;;AAGaA,IAAAA,SAAS,0BAAAC,KAAA,EAAA;AAAA,EAAA,SAAAD,SAAA,GAAA;AAAA,IAAA,IAAAE,KAAA;AAAAC,IAAAA,eAAA,OAAAH,SAAA,CAAA;AAAA,IAAA,KAAA,IAAAI,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAC,IAAA,GAAAC,IAAAA,KAAA,CAAAJ,IAAA,GAAAK,IAAA,GAAA,CAAA,EAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA,EAAA,EAAA;AAAAF,MAAAA,IAAA,CAAAE,IAAA,CAAAJ,GAAAA,SAAA,CAAAI,IAAA,CAAA;AAAA;AAAAP,IAAAA,KAAA,GAAAQ,UAAA,CAAA,IAAA,EAAAV,SAAA,EAAAW,EAAAA,CAAAA,MAAA,CAA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