Multiplayer - the best practices

0 favourites
  • 5 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • I'm about to play around with Multiplayer object. I read the tutorials etc. But all tutorials are based on client(peer) and server(host) code as one project.

    Isn't that dangerous to give client the hosts code? I'm just wondering what is the good practice in multi user games where host gonna be run 24/7 on separate server anyway.

    Is it a good practice to make separate projects for host and peer in C2?

  • It is. And since you are a backend freak you should probably use AJAX calling a responsive secure server-side application (like Java/Python/etc.).

    Then your game state is as secure as your server/server-side code is.

    Our (rough) architecture looks like this:

    User Browsers ---> Gateway Server ----> Client-side Server generation code

    ----> Client Side files

    ----> Core components

    ----> Security Library

    ----> In-memory data cache ----> Database

    I have a lot of Java servlets that mediate all of our game state, security, data caching/database, etc. Then I communicate to the C2 client either by direct variable injection using input TextBox tags or AJAX via our API.

  • Thanks gumshoe2029 for your reply. AJAX communication is just user<->server and it is very slow comparing to WebRTC and it is WebRTC (C2 Multiplayer object) I mean here.

    So I don't want to save the game state but do the real time multiplayer game. The point is that with Multiplayer object in C2 you sync C2 objects data, so I just was wondering how pros are doing this. Theoretically it is possible to split host and peer code, but due to the architecture I'm just wondering if it's not gonna be pain during development in further phase. So not sure if it's a good or bad idea.

    Haven't had time to play with it yet really.

  • Yea, I just found the WebSocket plugin, so I will begin tinkering with this now. I had built a Tomcat WebSocket server in Java earlier, but I didn't have a client to connect to it until now.

    The Multiplayer object was never really an option for us because our game state is maintained on our servers then the clients just ask for updates.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I wrote one multi-threaded Java server for WebSocket connection with AS3 game. It is pretty cool but it's more like for turn-based games/chat. Real-time games need peer-to-peer connections to works smoothly. It's fun experience, GL with your game.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)