Hello lovers!
I am relatively new at programming in lua, but i have created a 4 player pong game using the LUBE networking library. I setup a server and then clients can connect to it up to a maximum of 4 at a time and then they start playing, additionally i used the HardonCollider library to manage collisions and up until now it works fine. However, i want to establish a second server so that if the main server has been disconnected, a backup server would fulfill the role of a main server and viceversa. The problem is i don't really know how to do it. I would love it if you could help me out !!
PDT: sorry for my bad English D:
backup server for my game [Lube networking library]
- drunken_thor
- Citizen
- Posts: 75
- Joined: Wed Oct 01, 2014 12:14 am
- Location: Toronto, Canada
- Contact:
Re: backup server for my game [Lube networking library]
What is your motivation for that? It seems like the redundancy for such a case is lost on a 4 player pong game. There are two approaches to solving this
1. You would need to replicate game state across all servers
2. persist the game state in a replicable database and have a stateless server to access it.
Both scenarios would be absolutely overkill for a pong game.
1. You would need to replicate game state across all servers
2. persist the game state in a replicable database and have a stateless server to access it.
Both scenarios would be absolutely overkill for a pong game.
Re: backup server for my game [Lube networking library]
I think you have misunderstood his question. He just wants to know how he can make the clients first try Server #1 and Server #2 afterwards.drunken_thor wrote:What is your motivation for that? It seems like the redundancy for such a case is lost on a 4 player pong game. There are two approaches to solving this
1. You would need to replicate game state across all servers
2. persist the game state in a replicable database and have a stateless server to access it.
Both scenarios would be absolutely overkill for a pong game.
Just disconnect the server, see where the connection screws up and how that is observable in lua and repeat the process with IP #2 if it has failed.
Re: backup server for my game [Lube networking library]
Thank you for your replies, but basically what i want to do is this.
1- Open main server and the backup server.
2 - Connect clients to the main server and start playing.
3- keep checking if the main server is alive, so that the backup server knows when to take its role.
4- If the main server dies, the game must continue, so i want the backup server to take the game state where it was left off and let them continue playing until either they finish the game or both servers disconnect.
The thing is that i don't know how i can switch from the main server to the backup server when the main server dies, and if it is connected to the backup server then switch from the main server to the backup server when the backup server dies. And if both the main server and the backup server die, the game must end or be put on hold or something if that makes sense.
And my motivation for this is basically a request from a teacher haha.
1- Open main server and the backup server.
2 - Connect clients to the main server and start playing.
3- keep checking if the main server is alive, so that the backup server knows when to take its role.
4- If the main server dies, the game must continue, so i want the backup server to take the game state where it was left off and let them continue playing until either they finish the game or both servers disconnect.
The thing is that i don't know how i can switch from the main server to the backup server when the main server dies, and if it is connected to the backup server then switch from the main server to the backup server when the backup server dies. And if both the main server and the backup server die, the game must end or be put on hold or something if that makes sense.
And my motivation for this is basically a request from a teacher haha.
-
- Party member
- Posts: 712
- Joined: Fri Jun 22, 2012 4:54 pm
- Contact:
Re: backup server for my game [Lube networking library]
Ah, now it makes sense - because, as thor said, this is absolute overkill for a pong game.Motta92 wrote: And my motivation for this is basically a request from a teacher haha.
You won't be able to get this done without a short pause in the game.
I haven't used LUBE yet, but there must be some way of noticing on a client that it disconnected/timed out.
I believe you should set the ping to a "low" number (1, for example). Once you notice a disconnect event, try to connect to the second server.
The second server could be a client itself, which is always connected to the main server.
If it times out, then it starts an actual server instance, using the last gamestate it had found on the main server.
With that said, getting this right is a very complicated task... I suggest getting a piece of paper and drawing/writing on it all the connections and the steps you need to take for the switching.
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Who is online
Users browsing this forum: No registered users and 10 guests