[erlang-questions] gen_event handler question

Camille Troillard tuscland@REDACTED
Tue Apr 28 23:12:38 CEST 2009


Hello,
I would like to know if it is possible to write an event handler that would
receive only certain notifications based on a simple criteria.

For example, say I have a server process that searches for USB devices, and
sends notifications whenever new devices are attached or detached.  I would
like to write a event handler that would register to only certain kind of
devices (based on an atom describing the device for example) or another
event handler that would match all devices.

I have tried to use different function clauses like :

* in a module :
handle_event({attach, device_type_A}, State) ->  ...
handle_event({detach, device_type_A}, State) ->  ...

* and, in another module :
handle_event({attach, device_type_B}, State) ->  ...
handle_event({detach, device_type_B}, State) ->  ...

And register those two event handlers with the same manager.  Unfortunately
it fails with a bad_function_clause error.  I was expecting that, but I'm
running out of ideas.

Am I overlooking something?


Best Regards,
Camille
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090428/0232b3e8/attachment.htm>


More information about the erlang-questions mailing list