@colyseus/sdk 0.17.24 → 0.17.26
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 +1 -1
- package/build/Client.mjs +1 -1
- package/build/Connection.cjs +7 -3
- package/build/Connection.cjs.map +1 -1
- package/build/Connection.mjs +7 -3
- package/build/Connection.mjs.map +1 -1
- package/build/HTTP.bkp.d.ts +103 -0
- package/build/HTTP.cjs +1 -1
- package/build/HTTP.mjs +1 -1
- package/build/Room.cjs +16 -10
- package/build/Room.cjs.map +1 -1
- package/build/Room.mjs +16 -10
- package/build/Room.mjs.map +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/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-cocos-creator.js +61 -17
- package/dist/colyseus-cocos-creator.js.map +1 -1
- package/dist/colyseus.d.ts +3969 -0
- package/dist/colyseus.js +61 -17
- package/dist/colyseus.js.map +1 -1
- package/dist/debug.js +22 -12
- package/dist/debug.js.map +1 -1
- package/package.json +8 -8
- package/src/Connection.ts +8 -2
- package/src/Room.ts +16 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colyseus/sdk",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.26",
|
|
4
4
|
"description": "Colyseus Multiplayer SDK for JavaScript/TypeScript",
|
|
5
5
|
"author": "Endel Dreyer",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@colyseus/msgpackr": "^1.11.2",
|
|
55
|
-
"@colyseus/schema": "^4.0.
|
|
55
|
+
"@colyseus/schema": "^4.0.7",
|
|
56
56
|
"tslib": "^2.1.0",
|
|
57
57
|
"ws": "^8.13.0",
|
|
58
|
-
"@colyseus/shared-types": "^0.17.
|
|
58
|
+
"@colyseus/shared-types": "^0.17.6",
|
|
59
59
|
"@colyseus/better-call": "^1.2.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"typescript": "^5.9.3",
|
|
83
83
|
"vite": "^5.0.11",
|
|
84
84
|
"vitest": "^2.1.1",
|
|
85
|
-
"@colyseus/core": "^0.17.
|
|
85
|
+
"@colyseus/core": "^0.17.30"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"@colyseus/core": "0.17.x"
|
|
@@ -100,11 +100,11 @@
|
|
|
100
100
|
"start": "vite --config example/vite.config.ts",
|
|
101
101
|
"build": "rollup -c rollup.config.mjs",
|
|
102
102
|
"build-dist-dts": "dts-bundle-generator --config dts-generator.json",
|
|
103
|
-
"build-ci": "tsc && npm run build && npm run build-dist-dts && npm run build-
|
|
104
|
-
"build-
|
|
103
|
+
"build-ci": "tsc && npm run build && npm run build-dist-dts && npm run build-release-assets",
|
|
104
|
+
"build-release-assets": "zip --junk-paths colyseus-sdk dist/colyseus*",
|
|
105
105
|
"build-all": "tsc && npm run build && npm run build-dist-dts && npm run copy-cocos-creator-files && npm run copy-construct3-files",
|
|
106
|
-
"copy-construct3-files": "cp dist/colyseus.js
|
|
107
|
-
"copy-cocos-creator-files": "cp dist/colyseus-cocos-creator.js cocos-creator-3-extension/colyseus-sdk/runtime/colyseus.js && cp dist/colyseus.d.ts cocos-creator-3-extension/colyseus-sdk/runtime",
|
|
106
|
+
"copy-construct3-files": "cp dist/colyseus.js ../../../colyseus-construct3/plugin/colyseus.js && cp dist/debug.js ../../../colyseus-construct3/plugin/colyseus-debug.js",
|
|
107
|
+
"copy-cocos-creator-files": "tsc test/dist-types-check.ts --noEmit --skipLibCheck && cp dist/colyseus-cocos-creator.js cocos-creator-3-extension/colyseus-sdk/runtime/colyseus.js && cp dist/debug.js cocos-creator-3-extension/colyseus-sdk/runtime/debug.js && cp dist/colyseus.d.ts cocos-creator-3-extension/colyseus-sdk/runtime",
|
|
108
108
|
"watch": "tsc -w",
|
|
109
109
|
"tslint": "tslint --project ."
|
|
110
110
|
}
|
package/src/Connection.ts
CHANGED
|
@@ -66,8 +66,14 @@ export class Connection implements ITransport {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
reconnect(queryParams: { reconnectionToken: string, skipHandshake?: boolean }): void {
|
|
69
|
-
const
|
|
70
|
-
|
|
69
|
+
const url = new URL(this.url);
|
|
70
|
+
|
|
71
|
+
// override query params
|
|
72
|
+
for (const key in queryParams) {
|
|
73
|
+
url.searchParams.set(key, queryParams[key]);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.transport.connect(url.toString(), this.options);
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
close(code?: number, reason?: string): void {
|
package/src/Room.ts
CHANGED
|
@@ -148,7 +148,10 @@ export class Room<
|
|
|
148
148
|
serializer.decoder = new Decoder(state as Schema);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
this.onLeave(() =>
|
|
151
|
+
this.onLeave(() => {
|
|
152
|
+
this.removeAllListeners();
|
|
153
|
+
this.destroy();
|
|
154
|
+
});
|
|
152
155
|
}
|
|
153
156
|
|
|
154
157
|
public connect(endpoint: string, options?: any, headers?: any) {
|
|
@@ -172,7 +175,6 @@ export class Room<
|
|
|
172
175
|
|
|
173
176
|
} else {
|
|
174
177
|
this.onLeave.invoke(e.code, e.reason);
|
|
175
|
-
this.destroy();
|
|
176
178
|
}
|
|
177
179
|
};
|
|
178
180
|
|
|
@@ -340,6 +342,8 @@ export class Room<
|
|
|
340
342
|
this.onStateChange.clear();
|
|
341
343
|
this.onError.clear();
|
|
342
344
|
this.onLeave.clear();
|
|
345
|
+
this.onReconnect.clear();
|
|
346
|
+
this.onDrop.clear();
|
|
343
347
|
this.onMessageHandlers.events = {};
|
|
344
348
|
|
|
345
349
|
if (this.serializer instanceof SchemaSerializer) {
|
|
@@ -470,6 +474,7 @@ export class Room<
|
|
|
470
474
|
private handleReconnection() {
|
|
471
475
|
if (Date.now() - this.joinedAtTime < this.reconnection.minUptime) {
|
|
472
476
|
console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x274C)} Room has not been up for long enough for automatic reconnection. (min uptime: ${this.reconnection.minUptime}ms)`); // ❌
|
|
477
|
+
this.onLeave.invoke(CloseCode.ABNORMAL_CLOSURE, "Room uptime too short for reconnection.");
|
|
473
478
|
return;
|
|
474
479
|
}
|
|
475
480
|
|
|
@@ -482,6 +487,14 @@ export class Room<
|
|
|
482
487
|
}
|
|
483
488
|
|
|
484
489
|
private retryReconnection() {
|
|
490
|
+
if (this.reconnection.retryCount >= this.reconnection.maxRetries) {
|
|
491
|
+
// No more retries
|
|
492
|
+
console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x274C)} ❌ Reconnection failed after ${this.reconnection.maxRetries} attempts.`); // ❌
|
|
493
|
+
this.reconnection.isReconnecting = false;
|
|
494
|
+
this.onLeave.invoke(CloseCode.FAILED_TO_RECONNECT, "No more retries. Reconnection failed.");
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
|
|
485
498
|
this.reconnection.retryCount++;
|
|
486
499
|
|
|
487
500
|
const delay = Math.min(this.reconnection.maxDelay, Math.max(this.reconnection.minDelay, this.reconnection.backoff(this.reconnection.retryCount, this.reconnection.delay)));
|
|
@@ -497,12 +510,7 @@ export class Room<
|
|
|
497
510
|
});
|
|
498
511
|
|
|
499
512
|
} catch (e) {
|
|
500
|
-
|
|
501
|
-
if (this.reconnection.retryCount < this.reconnection.maxRetries) {
|
|
502
|
-
this.retryReconnection();
|
|
503
|
-
} else {
|
|
504
|
-
console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x274C)} Failed to reconnect. Is your server running? Please check server logs.`); // ❌
|
|
505
|
-
}
|
|
513
|
+
this.retryReconnection();
|
|
506
514
|
}
|
|
507
515
|
}, delay);
|
|
508
516
|
}
|