@leofcoin/peernet 0.14.22 → 0.14.24

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.
@@ -437,6 +437,7 @@ class Peer {
437
437
  this.#connection.ondatachannel = (message) => {
438
438
  message.channel.onopen = () => {
439
439
  this.#connected = true
440
+ debug(`peer:connected ${this}`)
440
441
  pubsub.publish('peer:connected', this)
441
442
  }
442
443
  message.channel.onclose = () => this.close.bind(this)
@@ -508,11 +509,12 @@ class Peer {
508
509
 
509
510
  async _in(message, data) {
510
511
  // message = JSON.parse(message);
511
- if (message.to !== this.id) return
512
+ if (!this.#connection || message.to !== this.id || message.from !== this.#peerId) return
512
513
  // if (data.videocall) return this._startStream(true, false); // start video and audio stream
513
514
  // if (data.call) return this._startStream(true, true); // start audio stream
514
515
  if (this.#connection?.signalinState === 'stable' && this.#connection?.remoteDescription !== null && this.#connection?.localDescription !== null) return
515
516
 
517
+
516
518
  if (message.candidate) {
517
519
  debug(`incoming candidate ${this.#channelName}`)
518
520
  // debug(message.candidate.candidate)
@@ -436,6 +436,7 @@ class Peer {
436
436
  this.#connection.ondatachannel = (message) => {
437
437
  message.channel.onopen = () => {
438
438
  this.#connected = true
439
+ debug(`peer:connected ${this}`)
439
440
  pubsub.publish('peer:connected', this)
440
441
  }
441
442
  message.channel.onclose = () => this.close.bind(this)
@@ -507,11 +508,12 @@ class Peer {
507
508
 
508
509
  async _in(message, data) {
509
510
  // message = JSON.parse(message);
510
- if (message.to !== this.id) return
511
+ if (!this.#connection || message.to !== this.id || message.from !== this.#peerId) return
511
512
  // if (data.videocall) return this._startStream(true, false); // start video and audio stream
512
513
  // if (data.call) return this._startStream(true, true); // start audio stream
513
514
  if (this.#connection?.signalinState === 'stable' && this.#connection?.remoteDescription !== null && this.#connection?.localDescription !== null) return
514
515
 
516
+
515
517
  if (message.candidate) {
516
518
  debug(`incoming candidate ${this.#channelName}`)
517
519
  // debug(message.candidate.candidate)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/peernet",
3
- "version": "0.14.22",
3
+ "version": "0.14.24",
4
4
  "description": "",
5
5
  "source": "src/peernet.js",
6
6
  "main": "dist/commonjs/peernet.js",