(Not) Another Networking Thread

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
RaycatRakittra
Prole
Posts: 22
Joined: Fri Sep 30, 2016 12:40 am
Location: Chicago, IL
Contact:

(Not) Another Networking Thread

Post by RaycatRakittra » Wed Oct 05, 2016 2:28 pm

I know, I know.

I've seen the search results; doesn't take long before someone with sub-50 post count makes ~another~ networking thread. That being said, I need to know a few things. I'm not very experienced with networking. I've dabbled with it in the past but it's never been something I truly dove into... until now. I'm trying to build out a server (using Lua-Enet) that can:

1) broadcast its status to clients which can log them (client-server lobby thing),
2) handle ten concurrent connections,
3) handle sub-optimal play conditions,
4) and interpolate player actions during packet loss.

I know there's no easy way to do this but hopefully, this is a small enough project to warrant some good feedback. Here are my current questions:

1) If I wanted to make this server accessible to anyone with the client, how would I go about implementing it? I'm not talking IP to IP; I mean, an honest-to-goodness server lobby. My first thought was running LOVE behind an Nginx config in Docker somewhere. From my past experience, Nginx can act like a load balancer and Docker is just standard process isolation. Re: the server, I think it needs some type of heartbeat that runs on a separate thread. It gets a bit weird on the client-side though, as I'd want the client to disconnect if the server wasn't responsive. Would I have to await the heartbeat or set a threshold of some sort?

2) I've tried simulating lag by using this tool (https://github.com/tylertreat/comcast) and I don't have a CLUE on how to interpolate player action. To what degree should I attempt to predict the player? What should I do to rollback game state on client if there's a misunderstanding (assuming the server always wins in this regard)? In this respect, I wish Move or Die would release the .love file. I'd kill to see how they wrote their code.

That's all I have for know. LOVE (ha!) to hear your thoughts on this.
Sometimes, I can code things.

Mariscal
Prole
Posts: 16
Joined: Sat Jun 25, 2016 4:51 pm
Location: London
Contact:

Re: (Not) Another Networking Thread

Post by Mariscal » Fri Oct 07, 2016 10:29 am

Hi there!

I'm currently working on another game adding the online mode, in our case it's quite different as one of the clients also acts as a server, so essentially it is peer to peer.

About your questions, this is how I'm doing it myself... in case you can use it for reference:
Re: the server, I think it needs some type of heartbeat that runs on a separate thread. It gets a bit weird on the client-side though, as I'd want the client to disconnect if the server wasn't responsive. Would I have to await the heartbeat or set a threshold of some sort?
Our clients send a ping to the server every second, if they fail to receive a pong back from the server 5 consecutive times, we assume the server has gone down. This is, as far as I know, pretty much the standard (the use of a heartbeat system in some sort of fashion)
2) I've tried simulating lag by using this tool (https://github.com/tylertreat/comcast) and I don't have a CLUE on how to interpolate player action. To what degree should I attempt to predict the player? What should I do to rollback game state on client if there's a misunderstanding (assuming the server always wins in this regard)?
You might want to give this blog a read :) http://www.gabrielgambetta.com/fpm1.html
Currently working on Breaking Fast, a competitive 2D "mario kart alike" racing game! Already passed steam greenlight, hopefully soon to be released! :D

User avatar
RaycatRakittra
Prole
Posts: 22
Joined: Fri Sep 30, 2016 12:40 am
Location: Chicago, IL
Contact:

Re: (Not) Another Networking Thread

Post by RaycatRakittra » Fri Oct 07, 2016 6:56 pm

Mariscal wrote:
-snip-

Our clients send a ping to the server every second, if they fail to receive a pong back from the server 5 consecutive times, we assume the server has gone down. This is, as far as I know, pretty much the standard (the use of a heartbeat system in some sort of fashion)

-snip-

You might want to give this blog a read :) http://www.gabrielgambetta.com/fpm1.html
Thanks a lot for replying! I'm reading through the link now. Will update with findings.
Sometimes, I can code things.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 11 guests