Jump to content

Phaser + nodejs + MQTT


Recommended Posts

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

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

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


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...