Multiplayer - the best practices

Get help using Construct 2

Post » Tue Jan 19, 2016 10:09 pm

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?
Image
B
28
S
14
G
54
Posts: 854
Reputation: 31,137

Post » Fri Jan 22, 2016 6:26 pm

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.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,317
Reputation: 4,628

Post » Fri Jan 22, 2016 7:50 pm

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.
Image
B
28
S
14
G
54
Posts: 854
Reputation: 31,137

Post » Sat Jan 30, 2016 5:03 pm

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.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,317
Reputation: 4,628

Post » Sat Jan 30, 2016 11:58 pm

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.
Image
B
28
S
14
G
54
Posts: 854
Reputation: 31,137


Return to How do I....?

Who is online

Users browsing this forum: yme and 9 guests