Sign in to follow this  
rKallmeyer

Direct Object Messaging

Recommended Posts

rKallmeyer    396
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?

Share this post


Link to post
Share on other sites
Drew_Benton    1861
It sounds like you are trying to do what I have been trying to do the past few days [grin]. Mine just is not in the sense of networking.

If you want to take a look at my posts (Link 3 most reccomended):
Link 1 | Link 2 | Link 3
I don't know if they will be of any use, but there is A LOT of great help on them from the great people of this forum [smile]

From what I have been working with, it would be better to do the implementation first and then work with it. I mean planning is good, but you might find yourself unable to do what you planned when you start coding. Ok take a look at those links, they have more knowledge than I could sum up here. If you have any questions on anything I've posted, feel free to ask.

Other than that your design looks pretty much right. I mainly suggested that you start coding now just to see what you do and don't need. I mean even if you think that you have everything covered, you might need to add a bit more! I learned this from playing with the concepts some. Good luck!

Share this post


Link to post
Share on other sites
rKallmeyer    396
sharkyx:
how has it been working for you?

Drew_Benton:
Thanks, I really like your message class, the function call operator is a very neat idea. It seems like it will be easy to pack and unpack also, which means it's very well-suited for net-traversal. I'm going to take your advice and jump right in to coding, as it looks like noone can see and fundemental flaws in the basic design.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this