@beta-gamer/react 0.1.3 → 0.1.7
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/dist/index.js +11 -0
- package/dist/index.mjs +11 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -70,6 +70,17 @@ function BetaGamerProvider({ token, serverUrl = "https://api.beta-gamer.com", so
|
|
|
70
70
|
transports: ["websocket", "polling"]
|
|
71
71
|
});
|
|
72
72
|
setSocket(s);
|
|
73
|
+
s.on("connect_error", (err) => {
|
|
74
|
+
const msg = err.message?.toLowerCase() ?? "";
|
|
75
|
+
let reason = "Unable to connect to the game server.";
|
|
76
|
+
if (msg.includes("websocket") || msg.includes("transport")) reason = "Connection failed: server does not accept WebSocket connections.";
|
|
77
|
+
else if (msg.includes("timeout")) reason = "Connection timed out. Check your internet connection.";
|
|
78
|
+
else if (msg.includes("unauthorized") || msg.includes("401")) reason = "Connection refused: invalid or expired session token.";
|
|
79
|
+
else if (msg.includes("not found") || msg.includes("404")) reason = "Game server not found. Check your serverUrl.";
|
|
80
|
+
else if (msg.includes("cors")) reason = "Connection blocked by CORS policy.";
|
|
81
|
+
else if (err.message) reason = `Connection error: ${err.message}`;
|
|
82
|
+
alert(`[Beta Gamer] ${reason}`);
|
|
83
|
+
});
|
|
73
84
|
s.on("game:state", (state) => {
|
|
74
85
|
setGameState((prev) => ({ ...prev, ...state }));
|
|
75
86
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -27,6 +27,17 @@ function BetaGamerProvider({ token, serverUrl = "https://api.beta-gamer.com", so
|
|
|
27
27
|
transports: ["websocket", "polling"]
|
|
28
28
|
});
|
|
29
29
|
setSocket(s);
|
|
30
|
+
s.on("connect_error", (err) => {
|
|
31
|
+
const msg = err.message?.toLowerCase() ?? "";
|
|
32
|
+
let reason = "Unable to connect to the game server.";
|
|
33
|
+
if (msg.includes("websocket") || msg.includes("transport")) reason = "Connection failed: server does not accept WebSocket connections.";
|
|
34
|
+
else if (msg.includes("timeout")) reason = "Connection timed out. Check your internet connection.";
|
|
35
|
+
else if (msg.includes("unauthorized") || msg.includes("401")) reason = "Connection refused: invalid or expired session token.";
|
|
36
|
+
else if (msg.includes("not found") || msg.includes("404")) reason = "Game server not found. Check your serverUrl.";
|
|
37
|
+
else if (msg.includes("cors")) reason = "Connection blocked by CORS policy.";
|
|
38
|
+
else if (err.message) reason = `Connection error: ${err.message}`;
|
|
39
|
+
alert(`[Beta Gamer] ${reason}`);
|
|
40
|
+
});
|
|
30
41
|
s.on("game:state", (state) => {
|
|
31
42
|
setGameState((prev) => ({ ...prev, ...state }));
|
|
32
43
|
});
|