Since minecraft networks with multiple servers are common and steadily growing, there is a demand for cross-server communication.
General problem
Everyone who develops in a multi-server environment has everytime the same problem: “How do I communicate with the other servers?”
Unless you have something like an API plugin, like I wrote for my plugins, this will be a challenge.
Mixing plugins with different communication protocols, etc. may not be possible; so man plugins use their own socket on the server to communicate with itself on the other side.
Connecting to many servers on one root server and constantly sending data reduces the overall open socket count and can push a root server to its limits
Another challenge is writing a networking software that is good in performance and fail-safe.
Pioneer work
I think BungeeCord and the Plugin Channel are a good example how to give plugins a way to communicate with each other. By encapsulating a name as SubChannel and a Byte array into a message it seperates plugins from the actual networking and simplifies its uses.
Unfortunately on BungeeCord this only works if a player is connected, because this uses the player’s connection.
The same principle is used in my network plugin XServer and I think this approach is still the way to go… (unless you have a better idea, so please tell me).
Standardization
Basicaly the idea that we had was to put a standardized api into sponge and a basic cross-server networking.
If needed the connection would be automatically opened (via SSL handshake) and closed when not used and timed out.
A basic message would be a simple container class:
public class Message {
private final String subchannel;
private final byte[] content;
...
}
A server would be an instance of:
public interface NetworkServer {
public boolean isConnected();
public void sendMessage(Message message);
public InetSocketAddress getAddress();
...
}
A list of servers could be retrieved via a manager:
public interface NetworkManager {
public List<NetworkServer> getServers(); // get all server
public NetworkServer getHome(); // this server
}
A message would be received via events:
@SpongeEventHandler( sync = true )
@NetworkHandler( subchannel = "optional subchannel" )
public void onMessage(NetworkMessageIncomingEvent event) {
Message m = event.getMessage();
NetworkServer server = event.getSender();
// do something ...
}
Protocol
-
Handshake
- Packet ID (0x01) | … crypto information …
-
Message
- Packet ID (0x20) | SubChannel (String) | Content (ByteArray)
- …
Future
Additional goals could be to implement it as a P2P network.
Conclusion
I think this makes multi-server developing easier and it would be highly appreciated by most plugin developers.
What do you think?