Skip to content

Commit be8c314

Browse files
chore: include Engine.IO client v4
The ping-pong mechanism has been reverted (server now sends a ping and expects a pong from the client), so we cannot compute the latency like we did in previous versions. Release notes: https://github.com/socketio/engine.io-client/releases/tag/4.0.0
1 parent f2f4a4c commit be8c314

File tree

5 files changed

+1
-49
lines changed

5 files changed

+1
-49
lines changed

build/manager.d.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export declare class Manager extends Emitter {
1515
private _reconnectionDelayMax;
1616
private _timeout;
1717
private connecting;
18-
private lastPing;
1918
private encoding;
2019
private packetBuffer;
2120
private encoder;
@@ -118,12 +117,6 @@ export declare class Manager extends Emitter {
118117
* @api private
119118
*/
120119
onping(): void;
121-
/**
122-
* Called upon a packet.
123-
*
124-
* @api private
125-
*/
126-
onpong(): void;
127120
/**
128121
* Called with data.
129122
*

build/manager.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class Manager extends component_emitter_1.default {
4949
this.nsps = {};
5050
this.subs = [];
5151
this.connecting = [];
52-
this.lastPing = null;
5352
this.packetBuffer = [];
5453
if (uri && "object" === typeof uri) {
5554
opts = uri;
@@ -337,7 +336,6 @@ class Manager extends component_emitter_1.default {
337336
const socket = this.engine;
338337
this.subs.push(on_1.on(socket, "data", component_bind_1.default(this, "ondata")));
339338
this.subs.push(on_1.on(socket, "ping", component_bind_1.default(this, "onping")));
340-
this.subs.push(on_1.on(socket, "pong", component_bind_1.default(this, "onpong")));
341339
this.subs.push(on_1.on(socket, "error", component_bind_1.default(this, "onerror")));
342340
this.subs.push(on_1.on(socket, "close", component_bind_1.default(this, "onclose")));
343341
this.subs.push(on_1.on(this.decoder, "decoded", component_bind_1.default(this, "ondecoded")));
@@ -348,17 +346,8 @@ class Manager extends component_emitter_1.default {
348346
* @api private
349347
*/
350348
onping() {
351-
this.lastPing = Date.now();
352349
this.emitAll("ping");
353350
}
354-
/**
355-
* Called upon a packet.
356-
*
357-
* @api private
358-
*/
359-
onpong() {
360-
this.emitAll("pong", Date.now() - this.lastPing);
361-
}
362351
/**
363352
* Called with data.
364353
*
@@ -476,7 +465,6 @@ class Manager extends component_emitter_1.default {
476465
}
477466
this.packetBuffer = [];
478467
this.encoding = false;
479-
this.lastPing = null;
480468
this.decoder.destroy();
481469
}
482470
/**

lib/manager.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export class Manager extends Emitter {
3434
private _timeout: any;
3535

3636
private connecting: Array<Socket> = [];
37-
private lastPing: number = null;
3837
private encoding: boolean;
3938
private packetBuffer: Array<any> = [];
4039
private encoder: Encoder;
@@ -363,7 +362,6 @@ export class Manager extends Emitter {
363362
const socket = this.engine;
364363
this.subs.push(on(socket, "data", bind(this, "ondata")));
365364
this.subs.push(on(socket, "ping", bind(this, "onping")));
366-
this.subs.push(on(socket, "pong", bind(this, "onpong")));
367365
this.subs.push(on(socket, "error", bind(this, "onerror")));
368366
this.subs.push(on(socket, "close", bind(this, "onclose")));
369367
this.subs.push(on(this.decoder, "decoded", bind(this, "ondecoded")));
@@ -375,19 +373,9 @@ export class Manager extends Emitter {
375373
* @api private
376374
*/
377375
onping() {
378-
this.lastPing = Date.now();
379376
this.emitAll("ping");
380377
}
381378

382-
/**
383-
* Called upon a packet.
384-
*
385-
* @api private
386-
*/
387-
onpong() {
388-
this.emitAll("pong", Date.now() - this.lastPing);
389-
}
390-
391379
/**
392380
* Called with data.
393381
*
@@ -515,7 +503,6 @@ export class Manager extends Emitter {
515503

516504
this.packetBuffer = [];
517505
this.encoding = false;
518-
this.lastPing = null;
519506

520507
this.decoder.destroy();
521508
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"component-bind": "1.0.0",
2121
"component-emitter": "~1.3.0",
2222
"debug": "~3.1.0",
23-
"engine.io-client": "~3.4.0",
23+
"engine.io-client": "~4.0.0",
2424
"has-binary2": "~1.0.2",
2525
"indexof": "0.0.1",
2626
"parseqs": "0.0.6",

test/socket.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,6 @@ describe("socket", function () {
4747
}, 300);
4848
});
4949

50-
it("should ping and pong with latency", (done) => {
51-
const socket = io({ forceNew: true });
52-
socket.on("connect", () => {
53-
let pinged;
54-
socket.once("ping", () => {
55-
pinged = true;
56-
});
57-
socket.once("pong", (ms) => {
58-
expect(pinged).to.be(true);
59-
expect(ms).to.be.a("number");
60-
socket.disconnect();
61-
done();
62-
});
63-
});
64-
});
65-
6650
it("should change socket.id upon reconnection", (done) => {
6751
const socket = io({ forceNew: true });
6852
socket.on("connect", () => {

0 commit comments

Comments
 (0)