(peer)
| 136 | } |
| 137 | |
| 138 | _keepAlive(peer) { |
| 139 | this._cancelKeepAlive(peer); |
| 140 | var timeout = 30000; |
| 141 | if (!peer.lastBeat) { |
| 142 | peer.lastBeat = Date.now(); |
| 143 | } |
| 144 | if (Date.now() - peer.lastBeat > 2 * timeout) { |
| 145 | this._leaveRoom(peer); |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | this._send(peer, { type: 'ping' }); |
| 150 | |
| 151 | peer.timerId = setTimeout(() => this._keepAlive(peer), timeout); |
| 152 | } |
| 153 | |
| 154 | _cancelKeepAlive(peer) { |
| 155 | if (peer && peer.timerId) { |
no test coverage detected