playsocketjs 4.2.0 → 4.2.1
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/package.json
CHANGED
package/src/client/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { encode, decode } from "@msgpack/msgpack";
|
|
2
2
|
import CRDTManager from "../universal/crdtManager.js";
|
|
3
|
-
import
|
|
3
|
+
import { VERSION } from "../universal/constants.js";
|
|
4
4
|
|
|
5
5
|
const ERROR_PREFIX = "PlaySocket error: ";
|
|
6
6
|
const WARNING_PREFIX = "PlaySocket warning: ";
|
|
@@ -161,7 +161,7 @@ export default class PlaySocket {
|
|
|
161
161
|
this.#sendToServer({
|
|
162
162
|
type: "register",
|
|
163
163
|
id: this.#id,
|
|
164
|
-
version:
|
|
164
|
+
version: VERSION,
|
|
165
165
|
customData: this.#customData || undefined
|
|
166
166
|
});
|
|
167
167
|
}),
|
package/src/server/server.js
CHANGED
|
@@ -2,8 +2,7 @@ import { WebSocketServer } from "ws";
|
|
|
2
2
|
import { createServer } from "node:http";
|
|
3
3
|
import { encode, decode } from "@msgpack/msgpack";
|
|
4
4
|
import CRDTManager, { getUpdateDetails } from "../universal/crdtManager.js";
|
|
5
|
-
import
|
|
6
|
-
import { HEARTBEAT_INTERVAL } from "../universal/constants.js";
|
|
5
|
+
import { HEARTBEAT_INTERVAL, VERSION } from "../universal/constants.js";
|
|
7
6
|
|
|
8
7
|
const MAX_ROOM_SIZE = 500;
|
|
9
8
|
export const RECONNECT_GRACE_PERIOD = 5000; // Exported for use in tests
|
|
@@ -147,8 +146,8 @@ export default class PlaySocketServer {
|
|
|
147
146
|
switch (data.type) {
|
|
148
147
|
case "register": {
|
|
149
148
|
// Ensure client uses the same version as server
|
|
150
|
-
if (data.version !==
|
|
151
|
-
ws.send(encode({ type: "registration_failed", reason: `Version mismatch (client ${data.version ? "v" + data.version : "legacy"}, server v${
|
|
149
|
+
if (data.version !== VERSION) {
|
|
150
|
+
ws.send(encode({ type: "registration_failed", reason: `Version mismatch (client ${data.version ? "v" + data.version : "legacy"}, server v${VERSION}). Please reload the page, an update may have been released.` }), { binary: true });
|
|
152
151
|
return;
|
|
153
152
|
}
|
|
154
153
|
|