websocket hit errors after upgraded to 9.0.3 #398
Unanswered
resourceleap
asked this question in
Help Wanted!
Replies: 3 comments 1 reply
-
Hi! All 8.x Unity builds should be compatible with 9.x. I would like to help you, but I'm going to need more information. Could you provide me with some more code examples and error logs? Thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks Jeffrey,
We just switch mode to other fixes, will send you related codes once we switch back to this track.
Regards,
Brent
From: Jeffrey Lanters ***@***.***>
Reply to: jeffreylanters/react-unity-webgl ***@***.***>
Date: Monday, 20 June 2022 at 3:24 PM
To: jeffreylanters/react-unity-webgl ***@***.***>
Cc: resourceleap ***@***.***>, Author ***@***.***>
Subject: Re: [jeffreylanters/react-unity-webgl] websocket hit errors after upgraded to 9.0.3 (Discussion #398)
Hi! All 8.x Unity builds should be compatible with 9.x. I would like to help you, but I'm going to need more information. Could you provide me with some more code examples and error logs? Thanks!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi Jeffrey,
I have tried the codes, apparently the unityContext has been changed to web hook, all the previous useEffect is not recognizing the declared unityContext, thus it causes io component cannot be loaded, parameters cannot be passed into context, socket io cannot be recognized. What is the correct syntax to do below as per previous working version?
Original working version with 8.7.2:
```jsx
import React, { useEffect } from "react";
import Unity, { UnityContext } from "react-unity-webgl";
import jwtDecode from "jwt-decode";
const unityContext = new UnityContext({
loaderUrl: "build/Build/build.loader.js",
dataUrl: "build/Build/build.data",
frameworkUrl: "build/Build/build.framework.js",
codeUrl: "build/Build/build.wasm"
});
function Home() {
useEffect(() => {
unityContext.on("GameReady", function (message) {
console.log("message", message)
if (message === "Ready") {
console.log("Success");
try {
window.onmessage = (e) => {
if (e.data.name === "iframe_message") {
let user = jwtDecode(e.data.token);
console.log("GameManager", "RequestToken");
unityContext.send("GameManager", "RequestToken", JSON.stringify({
username: user,
token: e.data.token,
amount: e.data.allowanceAmount
}));
}
}
window.parent.postMessage({ name: "iframe_message" }, "*");
} catch (err) {
console.log("error", err);
}
}
else console.log("error");
});
}, []);
return (
<div>
<Unity
unityContext={unityContext}
matchWebGLToCanvasSize={true}
style={{ height: "90vh", marginTop: "5vh", width: "100%" }}
/>
</div>
);
}
export default Home
Problematic version with useEffect and parameters passing:
import React, { useEffect } from "react";
import { Unity, useUnityContext } from "react-unity-webgl";
import jwtDecode from "jwt-decode";
function Home() {
const unityContext = useUnityContext({
loaderUrl: "build/Build/build.loader.js",
dataUrl: "build/Build/build.data",
frameworkUrl: "build/Build/build.framework.js",
codeUrl: "build/Build/build.wasm"
});
useEffect(() => {
unityContext.on("GameReady", function (message) {
console.log("message", message)
if (message === "Ready") {
console.log("Success");
try {
window.onmessage = (e) => {
if (e.data.name === "iframe_message") {
let user = jwtDecode(e.data.token);
console.log("GameManager", "RequestToken");
unityContext.send("GameManager", "RequestToken", JSON.stringify({
username: user,
token: e.data.token,
amount: e.data.allowanceAmount
}));
}
}
window.parent.postMessage({ name: "iframe_message" }, "*");
} catch (err) {
console.log("error", err);
}
}
else console.log("error");
});
}, []);
return (
<div>
<Unity
unityProvider={unityContext}
matchWebGLToCanvasSize={true}
style={{ height: "90vh", marginTop: "5vh", width: "100%" }}
/>
</div>
);
}
export default Home
```
From: Jeffrey Lanters ***@***.***>
Reply to: jeffreylanters/react-unity-webgl ***@***.***>
Date: Monday, 20 June 2022 at 3:24 PM
To: jeffreylanters/react-unity-webgl ***@***.***>
Cc: resourceleap ***@***.***>, Author ***@***.***>
Subject: Re: [jeffreylanters/react-unity-webgl] websocket hit errors after upgraded to 9.0.3 (Discussion #398)
Hi! All 8.x Unity builds should be compatible with 9.x. I would like to help you, but I'm going to need more information. Could you provide me with some more code examples and error logs? Thanks!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We have been running on version 8.6.2, unfortunately, it's giving all sorts of memory problems causing chrome hang or throw onwheel errors. We saw release notes of latest version stated significant performance improvement and canvas loading fixes are added. After implementing 9.0.3, the memory doesn't seems to reduce when switching from loading 1 unity webGL game to another Unity webGL game. further more, socket IO which was working in 8.6.2 is now giving error:
react_devtools_backend.js:4026 - ReferenceError: io is not defined at eval (eval at _JS_Eval_EvalJS (build.framework.js:3:2606), :2:35) at ......
is there any solution to this?
Beta Was this translation helpful? Give feedback.
All reactions