Skip to content

Commit f613f04

Browse files
authored
Merge pull request feross#754 from feross/add-type
2 parents 497e0ca + 0e6a318 commit f613f04

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ class Peer extends stream.Duplex {
256256
}
257257
} else {
258258
this.emit('signal', { // request initiator to renegotiate
259+
type: 'transceiverRequest',
259260
transceiverRequest: { kind, init }
260261
})
261262
}
@@ -390,6 +391,7 @@ class Peer extends stream.Duplex {
390391
} else {
391392
this._debug('requesting negotiation from initiator')
392393
this.emit('signal', { // request initiator to renegotiate
394+
type: 'renegotiate',
393395
renegotiate: true
394396
})
395397
}
@@ -909,8 +911,8 @@ class Peer extends stream.Duplex {
909911
this._queuedNegotiation = false
910912
this._needsNegotiation() // negotiate again
911913
} else {
912-
this._debug('negotiate')
913-
this.emit('negotiate')
914+
this._debug('negotiated')
915+
this.emit('negotiated')
914916
}
915917
}
916918

@@ -922,6 +924,7 @@ class Peer extends stream.Duplex {
922924
if (this.destroyed) return
923925
if (event.candidate && this.trickle) {
924926
this.emit('signal', {
927+
type: 'candidate',
925928
candidate: {
926929
candidate: event.candidate.candidate,
927930
sdpMLineIndex: event.candidate.sdpMLineIndex,
@@ -984,6 +987,7 @@ class Peer extends stream.Duplex {
984987

985988
this._remoteStreams.push(eventStream)
986989
queueMicrotask(() => {
990+
this._debug('on stream')
987991
this.emit('stream', eventStream) // ensure all tracks have been added
988992
})
989993
})

test/negotiation.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ test('manual renegotiation', function (t) {
7070
peer1.on('connect', function () {
7171
peer1.negotiate()
7272

73-
peer1.on('negotiate', function () {
73+
peer1.on('negotiated', function () {
7474
t.pass('peer1 negotiated')
7575
})
76-
peer2.on('negotiate', function () {
76+
peer2.on('negotiated', function () {
7777
t.pass('peer2 negotiated')
7878
})
7979
})
@@ -91,24 +91,24 @@ test('repeated manual renegotiation', function (t) {
9191
peer1.once('connect', function () {
9292
peer1.negotiate()
9393
})
94-
peer1.once('negotiate', function () {
94+
peer1.once('negotiated', function () {
9595
t.pass('peer1 negotiated')
9696
peer1.negotiate()
97-
peer1.once('negotiate', function () {
97+
peer1.once('negotiated', function () {
9898
t.pass('peer1 negotiated again')
9999
peer1.negotiate()
100-
peer1.once('negotiate', function () {
100+
peer1.once('negotiated', function () {
101101
t.pass('peer1 negotiated again')
102102
})
103103
})
104104
})
105-
peer2.once('negotiate', function () {
105+
peer2.once('negotiated', function () {
106106
t.pass('peer2 negotiated')
107107
peer2.negotiate()
108-
peer2.once('negotiate', function () {
108+
peer2.once('negotiated', function () {
109109
t.pass('peer2 negotiated again')
110110
peer1.negotiate()
111-
peer1.once('negotiate', function () {
111+
peer1.once('negotiated', function () {
112112
t.pass('peer1 negotiated again')
113113
})
114114
})

0 commit comments

Comments
 (0)