diff --git a/build/manager.d.ts b/build/manager.d.ts index ae4a9898..a782bc17 100644 --- a/build/manager.d.ts +++ b/build/manager.d.ts @@ -15,7 +15,6 @@ export declare class Manager extends Emitter { private _reconnectionDelayMax; private _timeout; private connecting; - private lastPing; private encoding; private packetBuffer; private encoder; @@ -118,12 +117,6 @@ export declare class Manager extends Emitter { * @api private */ onping(): void; - /** - * Called upon a packet. - * - * @api private - */ - onpong(): void; /** * Called with data. * diff --git a/build/manager.js b/build/manager.js index b3272be6..e7212940 100644 --- a/build/manager.js +++ b/build/manager.js @@ -49,7 +49,6 @@ class Manager extends component_emitter_1.default { this.nsps = {}; this.subs = []; this.connecting = []; - this.lastPing = null; this.packetBuffer = []; if (uri && "object" === typeof uri) { opts = uri; @@ -337,7 +336,6 @@ class Manager extends component_emitter_1.default { const socket = this.engine; this.subs.push(on_1.on(socket, "data", component_bind_1.default(this, "ondata"))); this.subs.push(on_1.on(socket, "ping", component_bind_1.default(this, "onping"))); - this.subs.push(on_1.on(socket, "pong", component_bind_1.default(this, "onpong"))); this.subs.push(on_1.on(socket, "error", component_bind_1.default(this, "onerror"))); this.subs.push(on_1.on(socket, "close", component_bind_1.default(this, "onclose"))); 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 { * @api private */ onping() { - this.lastPing = Date.now(); this.emitAll("ping"); } - /** - * Called upon a packet. - * - * @api private - */ - onpong() { - this.emitAll("pong", Date.now() - this.lastPing); - } /** * Called with data. * @@ -476,7 +465,6 @@ class Manager extends component_emitter_1.default { } this.packetBuffer = []; this.encoding = false; - this.lastPing = null; this.decoder.destroy(); } /** diff --git a/lib/manager.ts b/lib/manager.ts index a16434b3..95b4afb0 100644 --- a/lib/manager.ts +++ b/lib/manager.ts @@ -34,7 +34,6 @@ export class Manager extends Emitter { private _timeout: any; private connecting: Array = []; - private lastPing: number = null; private encoding: boolean; private packetBuffer: Array = []; private encoder: Encoder; @@ -363,7 +362,6 @@ export class Manager extends Emitter { const socket = this.engine; this.subs.push(on(socket, "data", bind(this, "ondata"))); this.subs.push(on(socket, "ping", bind(this, "onping"))); - this.subs.push(on(socket, "pong", bind(this, "onpong"))); this.subs.push(on(socket, "error", bind(this, "onerror"))); this.subs.push(on(socket, "close", bind(this, "onclose"))); this.subs.push(on(this.decoder, "decoded", bind(this, "ondecoded"))); @@ -375,19 +373,9 @@ export class Manager extends Emitter { * @api private */ onping() { - this.lastPing = Date.now(); this.emitAll("ping"); } - /** - * Called upon a packet. - * - * @api private - */ - onpong() { - this.emitAll("pong", Date.now() - this.lastPing); - } - /** * Called with data. * @@ -515,7 +503,6 @@ export class Manager extends Emitter { this.packetBuffer = []; this.encoding = false; - this.lastPing = null; this.decoder.destroy(); } diff --git a/package.json b/package.json index 16f36acf..55c3a9a0 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "component-bind": "1.0.0", "component-emitter": "~1.3.0", "debug": "~3.1.0", - "engine.io-client": "~3.4.0", + "engine.io-client": "~4.0.0", "has-binary2": "~1.0.2", "indexof": "0.0.1", "parseqs": "0.0.6", diff --git a/test/socket.js b/test/socket.js index 8dea4d5e..1a883e3c 100644 --- a/test/socket.js +++ b/test/socket.js @@ -47,22 +47,6 @@ describe("socket", function () { }, 300); }); - it("should ping and pong with latency", (done) => { - const socket = io({ forceNew: true }); - socket.on("connect", () => { - let pinged; - socket.once("ping", () => { - pinged = true; - }); - socket.once("pong", (ms) => { - expect(pinged).to.be(true); - expect(ms).to.be.a("number"); - socket.disconnect(); - done(); - }); - }); - }); - it("should change socket.id upon reconnection", (done) => { const socket = io({ forceNew: true }); socket.on("connect", () => {