Skip to main content
GameDev.net gamedev.net
🔒 Locked

Generic Message System.

Started by tstrimp Apr 21, 2006 at 11:26 AM 6 replies 1.3k views
Original Post
tstrimp
tstrimp
In order to get my engine to integrate a scripting language well I'm trying to develop a generic message system that all kernel tasks can pass and receive. The issue I'm running into is how to identify messages. I'd rather not use integers and defines because I would like to be able to add and use custom messages strictly from the scripting side. Also, messages are going to need a type because tasks should be able to subscribe to specific messages along with a type of message. The last thing I need to support is the ability to allow certain tasks to hijack the message queue so I can do things like get text input instead of calling events. Are there any good articles on messaging systems and how they relate to a micro-kernel task system? Does anyone have any ideas/suggestions reguarding the messaging system? I should mention, I would also like this to be the primary form of communication between system tasks. Thanks for reading! Tim.
Calin
Calin
Quote:
Original post by tstrimp


Are there any good articles on messaging systems and how they relate to a micro-kernel task system? Does anyone have any ideas/suggestions reguarding the messaging system? I should mention, I would also like this to be the primary form of communication between system tasks.



I'd be interested too.

Quote:

I'd rather not use integers and defines because I would like to be able to add and use custom messages strictly from the scripting side.


I'm using strings for my game. You can cut, trim and bake them as you wish.
My project`s facebook page is “DreamLand Page”
tstrimp
tstrimp
I'm using strings for task names currently but if I get messages working between tasks then I should be able to remove them because they will not need to be accessed by name, just alerted to new messages that they have subscribed to.
marcusz
marcusz
Easy speed+memory optimization:

use 32-bit ID:s for the message type. The ID:s are actually a hash-value you calculate from a string. This is may be the best of two worlds.

unsigned long exampleMessageType = Calc32BitHashFromString("RenderTextureMessageType");
SendMessage(exampleMessageType);


/Marcus
_swx_
_swx_
So how do you deal with collisions?
Evil Steve
Evil Steve
Quote:
Original post by _swx_
So how do you deal with collisions?
The easiest way would be to assert() if you get a collision, and just rename the message so it doesn't collide. That's what we did for State of Emergency 2 (Except it was for map identifiers, not messages).
leiavoia
leiavoia
Quote:
Original post by marcusz
Easy speed+memory optimization:

use 32-bit ID:s for the message type. The ID:s are actually a hash-value you calculate from a string. This is may be the best of two worlds.


Oooo, I'll stash that one away for later. Thanks!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.