Server/client resources, bundling and dev pipe

As some of you know, we are working on a online multiplayer game where the server is authoritative and most of the gamelogic is ran there.
Defold has been amazing in the way of developing both server and client side by side in the same project, actually just in 2 different collections. I have just switched which main collection to load and have had a very smooth pipe when developing both client and server. The server will in the end run headless but I can anytime I want switch over to a visual representation of whats going on and see that everything is behaving correctly serverside. A few lua modules are shared between those collections (mostly config)

As we are coming closer to some kind of release the questions about how to better bundle and divide these collections are rising. Right now the bundle on server contains all collections and resources for the client (which of course is unnecessary). But worse, all the server code is on every client which is of course vulnerable in so many ways (server has secret keys to the backend, all behaviour is in there and will make it easier for hacking etc).

First solution that pops to mind is to use Live update functionality. Without actually ever letting anyone download the extra content.

So server would be an excluded collection from the client bundle and vice versa. Question is if this actually covers it? What about lua modules required in one single collection, are they excluded as well?
We are working heavily with different build scripts today already. Would any external script be able to solve this somehow?

Maybe as the only solution we will need to move server to another project and finally separate these two?

EDIT: Oh, one important aspect is that the levels we are designing is shared between both the collections. So when leveldesigner is changing in the visual leveleditor (eg placement for a wall), the collisionobjects for the wall is being altered and used for serverside meanwhile the visual placement is being altered and used on the client. This is a big reason we still would like to have it a single project.

Open for discussions and suggestions.

3 Likes

Not sure I follow. Why is the server bundled with the client? Is the client referencing the server collection somehow, and if so why?

There are two reasons that the client and server is in the same project right now.

  1. When starting up writing network code and it’s events it has been very helpful to be able to dev on client and server network at the same time. Just running X instances of the project, one being server and the rest clients. The iterations has been fast. As there was no way to have several projects open at the same time jumping between server and client code would be a mess. This has been proven very effective deep into development as server and client has been developed simultanously.

  2. Some assets are shared and must be the exakt same on server and client. Eg.

  • Events. The messages sent back and forth the clients and server. They are defined in a file, serialized and deserialized by the engine and needs to have the same definition, (size, types etc).

  • Level data. Levels are created as collections using both free placements of gameobjects and tilemaps. Even if the server only care about the collisionshapes and type of objects within the leveldata meanwhile the client only cares about the visual representation (and to some extent collision) of the leveldata it still benefits to be defined in one file to avoid different versions of the data. (this includes indexed spawnpoints and other extra metadata)

  • Config. Some configurations needs to be known both by the client and server. These are added and changed all the time and need to be identical on both.

For these reasons we are developing in one project BUT would like to bundle them separately.
Right now they are indeed referencing each other so we very fast can make changes on both, build it once and then run them through scripts (scripts only changing the game.project to start different collections). If not referenced the build would not include the other collection and we wouldn’t be able to run them.
As I write this I believe I understand what you mean. If not referenced then none of the lua modules or assets would be bundled as well. Then I could build and bundle both the server and client via bob and change the main bootstrap collection.

1 Like

Exactly. If you bundle with the client.collection as main collection then only files referenced by that collection would be included. If the client.collection doesn’t use any server scripts or modules then those would not be included in the bundle.

I totally understand the convenience of having it all in one project and I don’t think you would have to change this going forward,

3 Likes

Too easy to be seen. I guess I was blinded by the fact that todays solution makes me build both in 2 sec (unless rebuilding) and that solution will force me to wait 2x~25 sec for each iteration as bob will have to rebuild both versions. So I will stick with this one for somewhat longer and when getting closer to release switch to this obvious solution.

4 Likes