Skip to content

Polymorphic message dispatch

mookid8000 edited this page Jun 5, 2012 · 3 revisions

Polymorphic message dispatch consists of doing multiple handler lookups for each incoming message - i.e. for each incoming message, a handler pipeline will be made, consisting of all handlers that handle the specified message including handlers that handle any superclass of the message.

For example this event:

public class SomeCompositeEvent : ISomethingHappened, ISomethingElseHappened { ... }

that clearly consists of the composition of two discrete events, ISomethingHappened and ISomethingElseHappened. Dispatching SomeCompositeEvent will thus result in dispatching to handlers that implement the following interfaces:

IHandleMessages<SomeCompositeEvent>
IHandleMessages<ISomeHappened>
IHandleMessages<ISomethingElseHappened>
IHandleMessages<object>

Yea, that's right: If a handler implements IHandleMessages<object>, it will get all messages :)

Clone this wiki locally