Skip to content

Commit c823ee3

Browse files
committed
feat: connect and disconnect events
1 parent 4e00ca2 commit c823ee3

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lite.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ class Peer extends Duplex {
299299
this._debug('destroying (error: %s)', err && (err.message || err))
300300

301301
setTimeout(() => { // allow events concurrent with the call to _destroy() to fire (see #692)
302+
if (this._connected) this.emit('disconnect')
302303
this._connected = false
303304
this._pcReady = false
304305
this._channelReady = false
@@ -719,6 +720,7 @@ class Peer extends Duplex {
719720
} else {
720721
this._connecting = false
721722
this._connected = true
723+
this.emit('connect')
722724
}
723725

724726
if (this._chunk) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@thaunknown/simple-peer",
33
"description": "Simple one-to-one WebRTC video/voice and data channels",
4-
"version": "10.0.11",
4+
"version": "10.0.12",
55
"type": "module",
66
"author": {
77
"name": "ThaUnknown",

0 commit comments

Comments
 (0)