I want to use publish/subscribe pattern to implement communication between game engine parts. But the problem is that I cannot find any articles about how it must be implemented in games. Can you, please, give me some useful hints and links on this topic
Publish-subscribe pattern
-
Lektet
- Gnoblar
- Posts: 21
- Joined: Sun May 01, 2011 5:30 pm
- x 2
Publish-subscribe pattern
Hello.
I want to use publish/subscribe pattern to implement communication between game engine parts. But the problem is that I cannot find any articles about how it must be implemented in games. Can you, please, give me some useful hints and links on this topic
I want to use publish/subscribe pattern to implement communication between game engine parts. But the problem is that I cannot find any articles about how it must be implemented in games. Can you, please, give me some useful hints and links on this topic
-
Klaim
- Old One
- Posts: 2565
- Joined: Sun Sep 11, 2005 1:04 am
- Location: Paris, France
- x 56
Re: Publish-subscribe pattern
It's because it's not called that way.
The abstract pattern is called the Observer pattern. There are tons of ways to implement it and it's always relative to several properties you want it to provide.
It's also often called "event system" or event something.
You will find tons of examples and explorative implementations (in C++ at least) by using "observer pattern" in your google research.
The abstract pattern is called the Observer pattern. There are tons of ways to implement it and it's always relative to several properties you want it to provide.
It's also often called "event system" or event something.
You will find tons of examples and explorative implementations (in C++ at least) by using "observer pattern" in your google research.
-
skyforger
- Halfling
- Posts: 49
- Joined: Tue Apr 13, 2010 10:23 am
- Location: Transylvania
- x 5
Re: Publish-subscribe pattern
The Observer pattern ( http://en.wikipedia.org/wiki/Observer_pattern ) is not the Publish–subscribe pattern ( http://en.wikipedia.org/wiki/Publish%E2 ... be_pattern ).Klaim wrote:It's because it's not called that way.
If you want to make an apple pie from scratch, you must first create the universe. ~Carl Sagan
-
Klaim
- Old One
- Posts: 2565
- Joined: Sun Sep 11, 2005 1:04 am
- Location: Paris, France
- x 56
Re: Publish-subscribe pattern
It's the same idea, one focused on observing one entity's event, the other on observing specific event types occurences.
Whatever way you got, there are also other concerns : does it have to be direct notifications? do they have to be buffered? thread-safe? etc.
Whatever way you got, there are also other concerns : does it have to be direct notifications? do they have to be buffered? thread-safe? etc.
-
skyforger
- Halfling
- Posts: 49
- Joined: Tue Apr 13, 2010 10:23 am
- Location: Transylvania
- x 5
Re: Publish-subscribe pattern
Mostly, you are correct. But the difference is: the publishers are unknown to the listeners, and the listeners only subscribe to a class of publishers, without knowledge of what they may actually be. They are more loosely coupled than the Observer pattern.Klaim wrote:It's the same idea, one focused on observing one entity's event, the other on observing specific event types occurences.
If you want to make an apple pie from scratch, you must first create the universe. ~Carl Sagan
-
Klaim
- Old One
- Posts: 2565
- Joined: Sun Sep 11, 2005 1:04 am
- Location: Paris, France
- x 56
Re: Publish-subscribe pattern
Yes, and there are tradeoff to take account about because none of those solutions is perfect.