Original Post
I would like get some feedback on a simple network design, to find out if it is flawed; I'd rather redesign sooner then later ;) Network connection and packet reliability isn't really the topic here, I'm working with messaging design. I would like to use a direct object messaging scheme where all classes inherit from a base class Object. class Object will have a virtual function HandleNetMessage (NetMessage*) which will be implimented in each derived class. Every derived Object will be given a unique ObjectID via the Object() constructor, and all corresponding objects on all machines will have the same ObjectID. For example: if Enemy32 in room4 has an ObjectID of 45556 on the server machine, then Enemy32 in room4 has an ObjectID of 45556 on the client machine as well. This allows me to send messages to local objects, and assure that the corresponding objects on different machines will receive the same messages. The details of Network implimentation will be hidden from the core library by a static interface class INetwork. INetwork contains a pointer to class Network, which is a base class that lays out common functionality between the 4 derived Network classes: NullNetwork - for single player games ClientNetwork - for client machines ServerNetwork - for server machines PeerNetwork - for peer machines (for fewer players) The base Network class has 2 important functions dealing with NetMessage's: SendTo (ObjectID targetObject, NetMessage*) - for sending messages Poll () - for receiving messages, and calling the target object's HandleNetMessage () function. Poll() will be called once per frame and it will keep dispatching messages until none are left. When INetwork is initialized, it will create one of the derived Network objects, depending on the specifics of the game and whether or not the specific machine is a host or not. From then on- all calls to SendTo() or Poll() will use the specific Network Object's implimentation. Here is a description of each: NullNetwork: (for single player games) SendTo () sends messages to local objects Poll () does nothing ClientNetwork: SendTo () sends messages to local objects sends messages to server Poll () receives messages, and sends to local objects ServerNetwork: *note that server machines will be running the game as well SendTo () sends messages to local objects sends messages to all clients Poll () sends messages to local objects resends messages to all clients except the source client PeerNetwork: *note, all machines will use PeerNetork if any of them do SendTo () sends messages to local objects sends messages to all other peers Poll () sends messages to local objects And that is the meat of it. The biggest problem I can see is that messages will arrive in a different order on every machine. I would like to try and design the message handling in such a way that these differences don't effect the play of the game in any significant way - assuming that they still all arrive in about the same time, just different order. Okay ... Thanks for taking a look at this, now what might I be missing?