MCPcopy
hub / github.com/SnapDrop/snapdrop / _keepAlive

Method _keepAlive

server/index.js:138–152  ·  view source on GitHub ↗
(peer)

Source from the content-addressed store, hash-verified

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) {

Callers 1

_onConnectionMethod · 0.95

Calls 3

_cancelKeepAliveMethod · 0.95
_leaveRoomMethod · 0.95
_sendMethod · 0.95

Tested by

no test coverage detected