Hey there

Whats the right way to implement a custom-Event between two app's?
That's the way I have done this:

### file: ryu/app/app_one.py ###
import ryu.app.AppOne
...

class EventAppOne(event.EventBase):
    def __init__ ...
        ...

class AppOne(app_manager.RyuApp):
    def __init__ ...
        ...
    def foo(self, dp):
        self.send_event_to_observers(ryu.app.AppOne.EventAppOne(dp))

### file: ryu/app/app_two.py ###
from ryu.app import AppOne
...

class AppTwo(app_manager.RyuApp):
    def __init__ ...
        ...
    @set_ev_cls(AppOne.EventAppOne)
    def bar(self, ev):
        ...

The Problem is in the app_manager.py (or I do not understand how to
implement events is the reason...) in the method:

    def get_observers(self, ev, state):
        observers = []
        for k, v in self.observers.get(ev.__class__, {}).iteritems():
            if not state or not v or state in v:
                observers.append(k)

If you send the event to the oveservers as follows:

self.send_event_to_observers(EventAppOne(dp))

then the attribute ev.__class__ in def get_observers(self, ev, state)
contains the key "AppOne.EventAppOne" but in the observers dict is the
key "ryu.app.AppOne.EventAppOne". So the event is not thrown.

If you send the event like this (and described before):

self.send_event_to_observers(ryu.app.AppOne.EventAppOne(dp))

then the attribute ev.__class__ in def get_observers(self, ev, state)
contains the right value that is "ryu.app.AppOne.EventAppOne" which is
the same as the key in observers dict and the event is thrown.

I hope I explained it correctly.

g *pae

--
ZHAW - Zurich University of Applied Sciences
Institute of Applied Information Technology InIT
InIT Cloud Computing Laboratory ICCLab

Philipp Aeschlimann
Researcher
Obere Kirchgasse 2
CH-8401 Winterthur

Tel. +41 58 934 6964 (intern 6964)
mailto:[email protected]
www.zhaw.ch
www.cloudcomp.ch

GPG IDKey: 647E122E
Fingerprint: 47B7 8D8A 98D1 E91D 4B7C E261 D88C BE9E 647E 122E

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to