riho Posted May 5, 2016 Share Posted May 5, 2016 Hi everyone, i'm developing my first game with Phaser and i'm having some issues. I'm also using NodeJS for the web server part and MQTT for gathering messages sent by physical sensors activated when the players make a move. The video game part is a kind of running between several characters. Each character moves a few pixels when a message sent via the MQTT protocol is received on the NodeJS side. To make the character to move I have to catch an information (message received) coming from the NodeJS side. For simplifying the question, how do I do to get on the Phaser front side variables that are defined on NodeJS Thanks a lot for your help Link to comment Share on other sites More sharing options...
drhayes Posted May 6, 2016 Share Posted May 6, 2016 You're trying to pass a value read from Node to the client side. There's several ways of doing this: 1. Poll the server from your Phaser game. Keep making AJAX calls (somehow) to ask the server for the value. 2. Use WebSockets. The Phaser game opens a WebSocket to the Node server and, when the server sends a message, the client interprets that message and saves the value. 3. User ServerSentEvents. I would do this one. It sounds a lot like the communication is one-way, from server to client. SSEs handle a lot of complexity for you, have wide browser support, and are made for problems like these. Good luck! Link to comment Share on other sites More sharing options...
riho Posted May 6, 2016 Author Share Posted May 6, 2016 Thank you drhayes for your advices. Moreover I have several solution to test I'll keep you posted as soon as I manage to make it work. I'll follow your recommendation by starting with SSE Link to comment Share on other sites More sharing options...
WombatTurkey Posted May 7, 2016 Share Posted May 7, 2016 On 5/5/2016 at 2:54 PM, riho said: for gathering messages sent by physical sensors activated when the players make a move. I recommend Websockets for that. You should get your hands dirty with Websockets while you're at it Link to comment Share on other sites More sharing options...
Recommended Posts