mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
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
This commit is contained in:
7
build/manager.d.ts
vendored
7
build/manager.d.ts
vendored
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,6 @@ export class Manager extends Emitter {
|
||||
private _timeout: any;
|
||||
|
||||
private connecting: Array<Socket> = [];
|
||||
private lastPing: number = null;
|
||||
private encoding: boolean;
|
||||
private packetBuffer: Array<any> = [];
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user