2013/3/1 can. <[email protected]>: > Thanks Kei, > > You mean a normal app does not need to call that method explicitly? And what > that method is supposed to do?
Yes. bin/ryu-manager.py creates Ryu app instance. Please see it. Thanks, > > > 2013/3/1 OHMURA Kei <[email protected]> >> >> 2013/3/1 can. <[email protected]>: >> > I think I get it. I should add ` self.register_observer(EventTest, >> > self.name) ` in TestEvent.__init__(). Thanks very much! >> > And I also see register_handler() in class RyuApp, when should I use it? >> >> IIUC, your app don't need to use it. >> >> Thanks, >> >> > >> > >> > 2013/3/1 can. <[email protected]> >> >> >> >> But I still cannot see the 'recv: xxx' as expected, here are the >> >> outputs: >> >> ----- >> >> loading app ryu.controller.ofp_handler >> >> loading app event.py >> >> instantiating app ryu.controller.ofp_handler >> >> instantiating app event.py >> >> ----- >> >> and nothing more. >> >> >> >> >> >> 2013/3/1 OHMURA Kei <[email protected]> >> >>> >> >>> 2013/3/1 can. <[email protected]>: >> >>> > What I want is a minimal example of handling event, including: >> >>> > 1) define an event >> >>> > 2) send an event >> >>> > 3) receive an event >> >>> >> >>> The following code would help your understanding? >> >>> >> >>> -- >> >>> import gevent >> >>> >> >>> from ryu.base import app_manager >> >>> from ryu.controller import event >> >>> from ryu.controller.handler import set_ev_cls >> >>> >> >>> >> >>> TEST_EVENT_EV_DISPATCHER = "test_event" >> >>> >> >>> >> >>> class EventTest(event.EventBase): >> >>> def __init__(self, msg): >> >>> super(EventTest, self).__init__() >> >>> self.msg = msg >> >>> >> >>> >> >>> class TestEvent(app_manager.RyuApp): >> >>> def __init__(self): >> >>> super(TestEvent, self).__init__() >> >>> self.name = 'test_event' >> >>> gevent.spawn_later(0, self._send_event_loop) >> >>> >> >>> def _send_event_loop(self): >> >>> i = 0 >> >>> while True: >> >>> self.send_event_to_observers(EventTest(i)) >> >>> i += 1 >> >>> gevent.sleep(1) >> >>> >> >>> @set_ev_cls(EventTest, TEST_EVENT_EV_DISPATCHER) >> >>> def _recv_handler(self, ev): >> >>> print 'recv:', ev.msg >> >> >> >> >> >> >> >> >> >> -- >> >> Best regards, >> >> Can Zhang >> > >> > >> > >> > >> > -- >> > Best regards, >> > Can Zhang >> > >> > >> > ------------------------------------------------------------------------------ >> > Everyone hates slow websites. So do we. >> > Make your web apps faster with AppDynamics >> > Download AppDynamics Lite for free today: >> > http://p.sf.net/sfu/appdyn_d2d_feb >> > _______________________________________________ >> > Ryu-devel mailing list >> > [email protected] >> > https://lists.sourceforge.net/lists/listinfo/ryu-devel >> > > > > > > -- > Best regards, > Can Zhang > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb > _______________________________________________ > Ryu-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/ryu-devel > ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
