Using Java Sockets to Communicate Between Servers in a Network

I recently got hired to re-write a large game in Minecraft, similar to classic Survival Games. It needs to run on a network, allowing for multiple game servers to go on as well as multiple servers to connect from.The servers the players can connect from needed to know the game status, map, mode (there were different types/remixes of gameplay), entry fee (cost to join), current player count, and maximum player count. All these would be displayed to players when viewing the ongoing games, and would also be used to partially judge whether or not a game would be open to players.

Minus a few features, the previous installation of the game used a MySQL database to store information about the server. I felt that MySQL was the wrong way to go about storing what should be stored in memory, and instead, I went the route of using a central server from which both game servers and join-from servers could contact for data, similar to Minecraft packets.The game network consisted of the game plugin/server, a plugin on the BungeeCord proxy network, and another for the join-from server.The game server would send data in the form of a JSON string to the Bungee socket server, which would then forward it to the join-from servers.

When a player wanted to join a game, the join-from server would send a packet to the game server (forwarded from Bungee) in order to double check that the data is consistent. If it all checked out, the Bungee server would send the player from their current server (storing it so they can be moved back later) to the game server, where the game server would handle every new player joining.

Leave a Reply

Your email address will not be published. Required fields are marked *