Library design for multiplayer

Hey Defold,

I’m currently writing server and client apps for a multiplayer game. Having set down a first pass network architecture (UDP move/attack, TCP talk, see e.g. this paper) I’m looking for how to break out my code into two projects.

  1. Server
  2. Client

They obviously should have synchronized game logic, most naturally from a shared set of modules. Is there a way to work with Defold Libraries that doesn’t involve uploading my source to the web? Not to be that guy, but closed source makes so much more sense if you’re trying to get in front of easy hacks.

Cheers

1 Like

If you are going to develop a small or mid size Indie Game, using UDP is a pain in the ass. I would recommend websocket (or any other TCP) for that kind of game and it would be more than enough.

1 Like

Security through obscurity never works. Your server code should be solid regardless if the attacker has access to your source or not.

Regardless, if you’re looking to split your code and share some of it across projects, you could try git submodules, but I’m not sure you’ll still be able to use the Editor’s built in Git client after that.

1 Like

Host the library project locally and serve it via a webserver to the editor. Or use a private GitHub repo (they are free nowadays.

Another option would be to have client and server code in the same repo and Defold project.

2 Likes

Oh! Can you do this with the Editor? I mean, for private repos you need to have the Authorization header to be able to download a zip, otherwise you get a 404.

1 Like

You should be able to create a personal access token and add it to the repo dependency url.

4 Likes

Ah, you’re right! Github’s API apparently supports basic auth, so you can do https://username:TOKEN@github.com/username/reponame/archive/master.zip

Cool!

6 Likes

Thanks Björn,

I’ll work on hosting it locally and post my solution here when I figure it out.

Cheers

1 Like

Got the javascript running:

New questions:

  1. Will the serverside need to be totally written in javascript?
  2. I’m planning to do {world state, game logic} server side, {assets, message formats & bindings} client side. Any obvious pitfalls to this architecture? Using sub/pub stream message passing for state updates from server and action propositions from clients.

have you finished it ?

Does this still work? I couldn’t figure it out.

Yes, it works. What kind of problem did you run into?

PS You create a personal access token like this:

https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line

hmm strange, not sure what I did, but it works now :slight_smile: