boardgameio / boardgame.io

State Management and Multiplayer Networking for Turn-Based Games
https://boardgame.io
MIT License
10.04k stars 709 forks source link

Confused at master (server) and client deployment #511

Closed somebody-vip closed 5 years ago

somebody-vip commented 5 years ago

Hi,

As as a novice beginner at Node and npm programming, I have just prototyped a small boardgame using boardgame.io after spending many hours. Testing on the local mockup server was so far so good. What I do is I run "node -r esm src/server.js" to launch a server (master) and run "npm start" to launch a local client.

But I now am facing some trouble in my attempt to actually deploy the server.

Do I basically need to deploy both a master (server) node application and at least one client node application to launch a finished game product (i.e. to deploy a production environment)?

And is there any way and how to deploy the master (server) on Heroku with free dynos?

I am also a little confused at why such a client layer is needed? When I first found boardgame.io, I thought it would just be all about defining game logics for the server, and that clients would simply be just different browser sessions connected to the server. Am I mis-understanding any of its concepts?

Any guidance is gracefully appreicated~

nicolodavis commented 5 years ago

Hi @somebody-vip.

Here is what the two layers do:

  1. The client layer is the code that will run on the user's browser. You have to deploy it to a web server somewhere (this is the web page that they visit).

  2. The server layer is a sort of controller that acts as an intermediary during multiplayer sessions. When a client makes a move, it sends it to this server, which then notifies other connected clients.

Your confusion might arise from why these are two separate things. For example, it is quite conceivable to have both these server processes run on one server. You can set up your deployment to work this way if you want (i.e. have the client code served from the same server that also handles the multiplayer communication). The reason that it is provided as separate components is so that you can also separate them if you like.

I don't use Heroku so I can't answer that question specifically. Maybe you can try asking on our Gitter channel?

somebody-vip commented 5 years ago

Thanks, Nicolo! Your explanation makes sense to me!