Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 5844 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, currently I''m planning a game and want to implement a generic messaging system which can handle nearby all messages in my game (graphics, sound, etc.). I''ve looked for some tutorials or articles but I didn''t found one (except those about the windows message queue). So I would like to know if somebody knows a good resource for it or some ideas how to create such a messaging system. Best Regards, Tealc

Share this post

Link to post
Share on other sites
I've never done this before but here goes.

Define a general (perhaps template) message object.

template <typename T>
class CMessage{
// these tell you who the message is from to

unsigned int m_uiFromID;
unsigned int m_uiToID;
// whatever other gear a message may need

unsigned int m_uiTimeStamp;
unsigned int m_uiPriority; ?? might be cool

then you can have messages specifically for sound

class CSoundMessage : public Message<CSound>{
// some extra info in the message which especially pertains

// to sound messages


if you don't use templates on CMessage then
you can have a general message queue which holds CMessages.
these can be CSoundMessage or whatever since they'll be type
or if you do you can have a separate queue for each resource,
one for sound one for graphics - this is where using templates
is good because it provides type safety.

class CMessageQueue{
std::queue m_Queue;
// whatever else

// returns the first message off the queue which is for you

T GetMessage(unsigned int uiToID);
// posts a message

PostMessage(T Message);

then you could go

class CSoundMessageQueue : CMessageQueue<CSoundMessage>{
// any other specifics you want for sound message queues


like I said before its something I made up as I went along, but it might work. however its probably a fairly average design, software architecture ain't my strong point.

good luck

Gobsmacked - by Toby Murray

[edited by - tobymurray on August 15, 2002 12:25:50 PM]

Share this post

Link to post
Share on other sites

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