Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Realization is a funny thing.

Sign in to follow this  


Ok, so realization set in last night as I got the server part running.

I need to come up with a protocol to allow the server and client to communicate. For one, text is exremely inefficient, and for another, why would I do it with text which would be required to be parsed? So today I have been sketching out a simple protocol that I will use to allow the client and server to communicate.

Basically it is going to work like this. I have a base command class that looks like this:

class CCommand
CCommand() { Type = COM_NONE; }
eComType Type;

For now, eComType is unimportant, it's an enumeration which will have each message type in it.

Now, using the magic of inheritance I can do this:

class CComDisplay : public CCommand
CComDisplay() { Type = COM_DISPLAY; }

char m_Message[128];

And when I pop that through the network, I can do something like this:

case COM_NONE:

Since every inherited command is a command, and contains the Type variable as the first variable in the class I can downcast it to the base type to check what it is. That will also allow me to know if the entire command is recieved from the network, as I only need to know the sizeof CCommand in order to check the type, then I know the size of the type to verify the size.

I'm fairly sure this will work and be expandable in the future. If anyone noticed something that I'm missing let me know.

After I get the command system coded, I'll need to import the entity system from my mud, with a few tweaks.

Then I have to work on the client :x

Or maybe I'll do some Lua scripting, who knows.

Edit (a couple hours later):
Ok, well that didn't take long, I've got the command passing and buffering code finished it looks like. I think I'll work on the entities.
Sign in to follow this  


Recommended Comments

There are no comments to display.

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
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!