You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 7, 2020. It is now read-only.
Arthur Pacaud edited this page Dec 1, 2019
·
1 revision
Now this is the tricky part. The problem here is that socketIO runs independently from GDevelop. That means that you can define socket.on definitions like on the server, but the problem comes from the interaction with the game, because the current instances of the objects describing the game (runtimeGame, runtimeScene) are not passed to the callback of the socket.on definition. So what you have to do is to add the socket.on definitions (same syntax as for the server). The socket object is located in SocketExt.socket. in the callback function, instead of directly modifying the game state, you will have to set some variables (JS not GDevelop variables) according to the recurved data. Then in the events of the scene, create a JS event that each frame checks those data for a value and do what you want in consequence.
To trigger an event on the server, use SocketExt.socket.emit("event keyword").