()
| 396 | } |
| 397 | |
| 398 | negotiate () { |
| 399 | if (this.destroying) return |
| 400 | if (this.destroyed) throw errCode(new Error('cannot negotiate after peer is destroyed'), 'ERR_DESTROYED') |
| 401 | |
| 402 | if (this.initiator) { |
| 403 | if (this._isNegotiating) { |
| 404 | this._queuedNegotiation = true |
| 405 | this._debug('already negotiating, queueing') |
| 406 | } else { |
| 407 | this._debug('start negotiation') |
| 408 | setTimeout(() => { // HACK: Chrome crashes if we immediately call createOffer |
| 409 | this._createOffer() |
| 410 | }, 0) |
| 411 | } |
| 412 | } else { |
| 413 | if (this._isNegotiating) { |
| 414 | this._queuedNegotiation = true |
| 415 | this._debug('already negotiating, queueing') |
| 416 | } else { |
| 417 | this._debug('requesting negotiation from initiator') |
| 418 | this.emit('signal', { // request initiator to renegotiate |
| 419 | type: 'renegotiate', |
| 420 | renegotiate: true |
| 421 | }) |
| 422 | } |
| 423 | } |
| 424 | this._isNegotiating = true |
| 425 | } |
| 426 | |
| 427 | // TODO: Delete this method once readable-stream is updated to contain a default |
| 428 | // implementation of destroy() that automatically calls _destroy() |
no test coverage detected