MCPcopy
hub / github.com/feross/simple-peer / addTransceiver

Method addTransceiver

index.js:257–275  ·  view source on GitHub ↗

* Add a Transceiver to the connection. * @param {String} kind * @param {Object} init

(kind, init)

Source from the content-addressed store, hash-verified

255 * @param {Object} init
256 */
257 addTransceiver (kind, init) {
258 if (this.destroying) return
259 if (this.destroyed) throw errCode(new Error('cannot addTransceiver after peer is destroyed'), 'ERR_DESTROYED')
260 this._debug('addTransceiver()')
261
262 if (this.initiator) {
263 try {
264 this._pc.addTransceiver(kind, init)
265 this._needsNegotiation()
266 } catch (err) {
267 this.destroy(errCode(err, 'ERR_ADD_TRANSCEIVER'))
268 }
269 } else {
270 this.emit('signal', { // request initiator to renegotiate
271 type: 'transceiverRequest',
272 transceiverRequest: { kind, init }
273 })
274 }
275 }
276
277 /**
278 * Add a MediaStream to the connection.

Callers 2

signalMethod · 0.95

Calls 3

_debugMethod · 0.95
_needsNegotiationMethod · 0.95
destroyMethod · 0.95

Tested by

no test coverage detected