On May 8, 2015, at 9:49 PM, 博威张 <zbw921...@gmail.com> wrote: > Hi, > > I have following confusions about the class of Switch (EventMixin) in > l2_multi : > 1.No instance of the class of Switch (EventMixin) has been found in component > of l2_multi, so how does it work?
Sure there are instances of it. The l2_multi class creates instances in response to ConnectionUp events. > 2. It doesn't listen to any components(including the core.openflow) , so how > will the function of _handle_PacketIn work? It listens to Connection objects. Switch.connect() does this by a call to self.listenTo(). As with the creation of Switch instances, the call to Switch.connect() is made from l2_multi's ConnectionUp handler. > 3. It doesn't raise any events and even doesn't have the _eventMixin_events > set, why does it inherit from revent.EventMixin? It inherits from it so that it can do self.listenTo() (which comes from EventMixin). This was briefly "the normal way" to bind events, but has been sort of deprecated for a long while. I guess it has never been replaced here, though. The more common/modern equivalent is calling source.addListeners(sink) rather than sink.listenTo(source). > Thank you! > Bowei >