I have solved this problem by use @set_ev_cls instead of @set_cls_handler.
But new question is that why ofp_handler use @set_ev_handler can handle the
event, and other app have to use @set_ev_clst?
The different of these two decorator is about ev.soource.
If use @set_ev_handelr, the ev.source will be None, which will be skipped when
call method _uppdate_brick at app_manager.
Why ofp_handler can work?
# should be named something like 'observe_event'
def set_ev_cls(ev_cls, dispatchers=None):
def _set_ev_cls_dec(handler):
if 'callers' not in dir(handler):
handler.callers = {}
for e in _listify(ev_cls):
handler.callers[e] = _Caller(_listify(dispatchers), e.__module__)
return handler
return _set_ev_cls_dec
def set_ev_handler(ev_cls, dispatchers=None):
def _set_ev_cls_dec(handler):
if 'callers' not in dir(handler):
handler.callers = {}
for e in _listify(ev_cls):
handler.callers[e] = _Caller(_listify(dispatchers), None)
return handler
return _set_ev_cls_dec
------------------
Distance ????
_____________________________________________________
School of Information and Communication Engineering
Beijing University of Posts and Telecommunications
Beijing 100876, PR China
??????????????????????????????????????????
_____________________________________________________
Mobile Phone:
(+86) 151-1698-3550 Beijing
E-mail:
[email protected]
[email protected]
Homepage:
http://www.muzixing.com
------------------ ???????? ------------------
??????: "muzixing.com";<[email protected]>;
????????: 2015??8??1??(??????) ????11:42
??????: "ryu-devel"<[email protected]>;
????: [Ryu-devel] How to register observes for self-defined event?
To whom it may concern,
I try to generate a self-defined event in Ryu. What I have done shows
below,
1. define a xxx_event.py and define a EventXXXX in this file.
2. In a Ryu app, import xxx_event. Call the
self.send_event_to_observers(ev, self.state)
3. In another Ryu app, decorated a method by
@set_ev_handler(xxx_event.EventXXXX, state)
However, I run the apps and return nothing.
I really generate a event which defined by me, and call the
method:send_event_to_observers.
I found that the observers of my event is empty, so the event can't be
pushed in the Queue.
How should I do to register the observer?
If I add the code below to call handles, the event will be handled,
because I handle the event directly.
dispatchers = lambda x: x.callers[ev.__class__].dispatchers
handlers = [handler for handler in
self.oxp_brick.get_handlers(ev) if
MAIN_DISPATCHER in dispatchers(handler)]
for handler in handlers:
handler(ev)
Thanks for your time.
I look forward to your reply.
Best Regards.
------------------
Distance ????
_____________________________________________________
School of Information and Communication Engineering
Beijing University of Posts and Telecommunications
Beijing 100876, PR China
??????????????????????????????????????????
_____________________________________________________
Mobile Phone:
(+86) 151-1698-3550 Beijing
E-mail:
[email protected]
[email protected]
Homepage:
http://www.muzixing.com------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel