@colyseus/sdk 0.17.42 → 0.17.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/3rd_party/discord.cjs +1 -1
- package/build/3rd_party/discord.mjs +1 -1
- package/build/Auth.cjs +1 -1
- package/build/Auth.mjs +1 -1
- package/build/Client.cjs +39 -10
- package/build/Client.cjs.map +1 -1
- package/build/Client.d.ts +11 -2
- package/build/Client.mjs +38 -10
- package/build/Client.mjs.map +1 -1
- package/build/Connection.cjs +1 -1
- package/build/Connection.mjs +1 -1
- package/build/HTTP.cjs +1 -1
- package/build/HTTP.mjs +1 -1
- package/build/Room.cjs +1 -1
- package/build/Room.mjs +1 -1
- package/build/Storage.cjs +1 -1
- package/build/Storage.mjs +1 -1
- package/build/core/nanoevents.cjs +1 -1
- package/build/core/nanoevents.mjs +1 -1
- package/build/core/signal.cjs +1 -1
- package/build/core/signal.mjs +1 -1
- package/build/core/utils.cjs +1 -1
- package/build/core/utils.mjs +1 -1
- package/build/debug.cjs +1 -1
- package/build/debug.mjs +1 -1
- package/build/errors/Errors.cjs +1 -1
- package/build/errors/Errors.mjs +1 -1
- package/build/fetchXHR.cjs +1 -1
- package/build/fetchXHR.mjs +1 -1
- package/build/index.cjs +1 -1
- package/build/index.mjs +1 -1
- package/build/legacy.cjs +1 -1
- package/build/legacy.mjs +1 -1
- package/build/serializer/NoneSerializer.cjs +1 -1
- package/build/serializer/NoneSerializer.mjs +1 -1
- package/build/serializer/SchemaSerializer.cjs +1 -1
- package/build/serializer/SchemaSerializer.mjs +1 -1
- package/build/serializer/Serializer.cjs +1 -1
- package/build/serializer/Serializer.mjs +1 -1
- package/build/transport/H3Transport.cjs +1 -1
- package/build/transport/H3Transport.mjs +1 -1
- package/build/transport/WebSocketTransport.cjs +1 -1
- package/build/transport/WebSocketTransport.mjs +1 -1
- package/dist/colyseus.js +39 -10
- package/dist/colyseus.js.map +1 -1
- package/dist/debug.js +1 -1
- package/package.json +2 -2
- package/src/Client.ts +41 -8
package/build/Storage.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// This software is released under the MIT License.
|
|
4
4
|
// https://opensource.org/license/MIT
|
|
5
5
|
//
|
|
6
|
-
// colyseus.js@0.17.
|
|
6
|
+
// colyseus.js@0.17.43
|
|
7
7
|
/// <reference path="../typings/cocos-creator.d.ts" />
|
|
8
8
|
/**
|
|
9
9
|
* We do not assign 'storage' to window.localStorage immediatelly for React
|
package/build/core/signal.cjs
CHANGED
package/build/core/signal.mjs
CHANGED
package/build/core/utils.cjs
CHANGED
package/build/core/utils.mjs
CHANGED
package/build/debug.cjs
CHANGED
package/build/debug.mjs
CHANGED
package/build/errors/Errors.cjs
CHANGED
package/build/errors/Errors.mjs
CHANGED
package/build/fetchXHR.cjs
CHANGED
package/build/fetchXHR.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// This software is released under the MIT License.
|
|
4
4
|
// https://opensource.org/license/MIT
|
|
5
5
|
//
|
|
6
|
-
// colyseus.js@0.17.
|
|
6
|
+
// colyseus.js@0.17.43
|
|
7
7
|
/**
|
|
8
8
|
* Minimal fetch-compatible wrapper around XMLHttpRequest.
|
|
9
9
|
* Used as an automatic fallback when globalThis.fetch is unavailable
|
package/build/index.cjs
CHANGED
package/build/index.mjs
CHANGED
package/build/legacy.cjs
CHANGED
package/build/legacy.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// This software is released under the MIT License.
|
|
4
4
|
// https://opensource.org/license/MIT
|
|
5
5
|
//
|
|
6
|
-
// colyseus.js@0.17.
|
|
6
|
+
// colyseus.js@0.17.43
|
|
7
7
|
import { decode, encode } from '@colyseus/schema';
|
|
8
8
|
|
|
9
9
|
// 9 bytes is the maximum length of a variable-length integer prefix
|
package/dist/colyseus.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// This software is released under the MIT License.
|
|
4
4
|
// https://opensource.org/license/MIT
|
|
5
5
|
//
|
|
6
|
-
// colyseus.js@0.17.
|
|
6
|
+
// colyseus.js@0.17.43 - @colyseus/schema 4.0.13
|
|
7
7
|
(function (global, factory) {
|
|
8
8
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
9
9
|
typeof define === 'function' && define.amd ? define('@colyseus/sdk', ['exports'], factory) :
|
|
@@ -9582,7 +9582,7 @@
|
|
|
9582
9582
|
* Select the endpoint with the lowest latency.
|
|
9583
9583
|
* @param endpoints Array of endpoints to select from.
|
|
9584
9584
|
* @param options Client options.
|
|
9585
|
-
* @param latencyOptions Latency measurement options (protocol, pingCount).
|
|
9585
|
+
* @param latencyOptions Latency measurement options (protocol, pingCount, timeout) — forwarded to each {@link getLatency} call.
|
|
9586
9586
|
* @returns The client with the lowest latency.
|
|
9587
9587
|
*/
|
|
9588
9588
|
static selectByLatency(endpoints_1, options_1) {
|
|
@@ -9661,16 +9661,41 @@
|
|
|
9661
9661
|
}
|
|
9662
9662
|
/**
|
|
9663
9663
|
* Create a new connection with the server, and measure the latency.
|
|
9664
|
-
*
|
|
9664
|
+
*
|
|
9665
|
+
* Always settles: resolves with the (average) round-trip time, or rejects on
|
|
9666
|
+
* connection error, server-side close before all pongs arrive, or timeout.
|
|
9667
|
+
*
|
|
9668
|
+
* @param options Latency measurement options (protocol, pingCount, timeout).
|
|
9665
9669
|
*/
|
|
9666
9670
|
getLatency(options = {}) {
|
|
9667
|
-
var _a, _b;
|
|
9671
|
+
var _a, _b, _c;
|
|
9668
9672
|
const protocol = (_a = options.protocol) !== null && _a !== void 0 ? _a : "ws";
|
|
9669
9673
|
const pingCount = (_b = options.pingCount) !== null && _b !== void 0 ? _b : 1;
|
|
9674
|
+
const timeout = (_c = options.timeout) !== null && _c !== void 0 ? _c : 1500;
|
|
9670
9675
|
return new Promise((resolve, reject) => {
|
|
9676
|
+
var _a;
|
|
9671
9677
|
const conn = new Connection(protocol);
|
|
9672
9678
|
const latencies = [];
|
|
9673
9679
|
let pingStart = 0;
|
|
9680
|
+
let settled = false;
|
|
9681
|
+
let timeoutId;
|
|
9682
|
+
// run exactly once — guards against late events after resolve/reject
|
|
9683
|
+
// (e.g. our own conn.close() firing onclose, or a stray onclose/onerror pair)
|
|
9684
|
+
const settle = (run) => {
|
|
9685
|
+
if (settled) {
|
|
9686
|
+
return;
|
|
9687
|
+
}
|
|
9688
|
+
settled = true;
|
|
9689
|
+
clearTimeout(timeoutId);
|
|
9690
|
+
try {
|
|
9691
|
+
conn.close();
|
|
9692
|
+
}
|
|
9693
|
+
catch (e) { /* socket may never have opened */ }
|
|
9694
|
+
run();
|
|
9695
|
+
};
|
|
9696
|
+
const fail = (message) => settle(() => reject(new ServerError(CloseCode.ABNORMAL_CLOSURE, `Failed to get latency: ${message}`)));
|
|
9697
|
+
// bound blackholed/filtered hosts that never fire onopen/onerror within the OS TCP timeout
|
|
9698
|
+
timeoutId = setTimeout(() => fail(`timed out after ${timeout}ms`), timeout);
|
|
9674
9699
|
conn.events.onopen = () => {
|
|
9675
9700
|
pingStart = Date.now();
|
|
9676
9701
|
conn.send(new Uint8Array([Protocol.PING]));
|
|
@@ -9684,15 +9709,19 @@
|
|
|
9684
9709
|
}
|
|
9685
9710
|
else {
|
|
9686
9711
|
// Done, calculate average and close
|
|
9687
|
-
conn.close();
|
|
9688
9712
|
const average = latencies.reduce((sum, l) => sum + l, 0) / latencies.length;
|
|
9689
|
-
resolve(average);
|
|
9713
|
+
settle(() => resolve(average));
|
|
9690
9714
|
}
|
|
9691
9715
|
};
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
9716
|
+
// server closed the socket before all pongs arrived — fires without onerror on a clean close
|
|
9717
|
+
conn.events.onclose = (event) => fail(`connection closed${(event === null || event === void 0 ? void 0 : event.code) ? ` (${event.code})` : ""}${(event === null || event === void 0 ? void 0 : event.reason) ? `: ${event.reason}` : ""}`);
|
|
9718
|
+
conn.events.onerror = (event) => fail(event.message);
|
|
9719
|
+
try {
|
|
9720
|
+
conn.connect(this.getHttpEndpoint());
|
|
9721
|
+
}
|
|
9722
|
+
catch (e) {
|
|
9723
|
+
fail((_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : "failed to connect");
|
|
9724
|
+
}
|
|
9696
9725
|
});
|
|
9697
9726
|
}
|
|
9698
9727
|
createMatchMakeRequest(method_1, roomName_1) {
|