Warning: Very technical thread ahead.
So the idea for the networking part is to use the netty library for network communication and send protocol buffers messages between clients and servers. In the best case these messages form a hierachy, so that they can be handled efficiently. I will start a brainstorm in this thread (paper or a notepad would have done the trick too) about the structure and hierachy of these messages. I will use some pseudo notation.
A bit of explanation. Message are just some data structures that are transferred over the internet. Because network communication is quite unreliable and speed is variable we must take many precautions. A good framework is essential. The messages by itself should also be well designed but since our experience grows while we are doing it, we just start with what looks best now and then we will improve.
Design of Network Messages
Forum rules
Posted relevant content can be used under GPL or GFDL (http://www.gnu.org/) for the project. Thanks!
Posted relevant content can be used under GPL or GFDL (http://www.gnu.org/) for the project. Thanks!
General Messages: Client Registration, ...
message: registerClient % client > server [
int ID % unique, random
String name % displayable name
]
% can only be sent once, disconnect to deregister
message: ping % client <> server []
% sent occasionally to detect errors early (like every 10 seconds) from both sides
message: shutdown % client > server[]
% only accepted when client local (maybe not needed)
message: willShutdown % server > client[]
% notify all connected clients that soon the server will shutdown
message: proposeGame % client > server [
???
]
% proposing a game automatically gives you the role "HOST"
message: startGame % client > server [
]
% maybe return a status enum {No Game proposed, Not enough other players, .., Will start soon}
message: gameStarted % server > client [
int ID % game ID in case there are more than one going on
]
% server notifies all clients
message: requestStopGame % client > server [
int ID % game ID
]
% one client wants to exit, save, ...(needs to be expanded later)
message: gameStopped % server > client [
int ID % game ID
]
% server tells client that a particular game is over
message: chat % client <> server [
String message
]
% can be sent from clients to server and from server to clients
int ID % unique, random
String name % displayable name
]
% can only be sent once, disconnect to deregister
message: ping % client <> server []
% sent occasionally to detect errors early (like every 10 seconds) from both sides
message: shutdown % client > server[]
% only accepted when client local (maybe not needed)
message: willShutdown % server > client[]
% notify all connected clients that soon the server will shutdown
message: proposeGame % client > server [
???
]
% proposing a game automatically gives you the role "HOST"
message: startGame % client > server [
]
% maybe return a status enum {No Game proposed, Not enough other players, .., Will start soon}
message: gameStarted % server > client [
int ID % game ID in case there are more than one going on
]
% server notifies all clients
message: requestStopGame % client > server [
int ID % game ID
]
% one client wants to exit, save, ...(needs to be expanded later)
message: gameStopped % server > client [
int ID % game ID
]
% server tells client that a particular game is over
message: chat % client <> server [
String message
]
% can be sent from clients to server and from server to clients
Comment
Phew, I just invented some basic messages and already it feels like a lot of work ahead. Also the hierachy is not clear to me at all.
There is a timing hierachy - without a registerClient, a client is not allowed to do anything and without a propose or joing game message there is no game started message possible.. but are there other hierachies as well.
And what is the difference between AI and Human. Should we introduce special roles for AI or just implement them with the same interface as a human client who's just ignoring things like chat messages? I prefer the later for now.
There is a timing hierachy - without a registerClient, a client is not allowed to do anything and without a propose or joing game message there is no game started message possible.. but are there other hierachies as well.
And what is the difference between AI and Human. Should we introduce special roles for AI or just implement them with the same interface as a human client who's just ignoring things like chat messages? I prefer the later for now.