Exemplo n.º 1
0
def _none(x):
    return None


DELEGATED = Constant("DELEGATED")


def _core(number, method):
    return EventType(number=number, method=method)


wrappers = {
    "pn_void": lambda x: pn_void2py(x),
    "pn_pyref": lambda x: pn_void2py(x),
    "pn_connection": lambda x: Connection.wrap(pn_cast_pn_connection(x)),
    "pn_session": lambda x: Session.wrap(pn_cast_pn_session(x)),
    "pn_link": lambda x: Link.wrap(pn_cast_pn_link(x)),
    "pn_delivery": lambda x: Delivery.wrap(pn_cast_pn_delivery(x)),
    "pn_transport": lambda x: Transport.wrap(pn_cast_pn_transport(x)),
    "pn_selectable": lambda x: Selectable.wrap(pn_cast_pn_selectable(x))
}


class Event(Wrapper, EventBase):
    REACTOR_INIT = _core(PN_REACTOR_INIT, "on_reactor_init")
    REACTOR_QUIESCED = _core(PN_REACTOR_QUIESCED, "on_reactor_quiesced")
    REACTOR_FINAL = _core(PN_REACTOR_FINAL, "on_reactor_final")

    TIMER_TASK = _core(PN_TIMER_TASK, "on_timer_task")

    CONNECTION_INIT = _core(PN_CONNECTION_INIT, "on_connection_init")
Exemplo n.º 2
0
        return "%s(%r)" % (self._type, self.context)


def _core(number, method):
    return EventType(number=number, method=method)


def _internal(name):
    return EventType(name=name)


wrappers = {
    "pn_void": lambda x: pn_void2py(x),
    "pn_pyref": lambda x: pn_void2py(x),
    "pn_connection": lambda x: Connection.wrap(pn_cast_pn_connection(x)),
    "pn_session": lambda x: Session.wrap(pn_cast_pn_session(x)),
    "pn_link": lambda x: Link.wrap(pn_cast_pn_link(x)),
    "pn_delivery": lambda x: Delivery.wrap(pn_cast_pn_delivery(x)),
    "pn_transport": lambda x: Transport.wrap(pn_cast_pn_transport(x))
}


class Event(EventBase):
    TIMER_TASK = _core(PN_TIMER_TASK, "on_timer_task")

    CONNECTION_INIT = _core(PN_CONNECTION_INIT, "on_connection_init")
    CONNECTION_BOUND = _core(PN_CONNECTION_BOUND, "on_connection_bound")
    CONNECTION_UNBOUND = _core(PN_CONNECTION_UNBOUND, "on_connection_unbound")
    CONNECTION_LOCAL_OPEN = _core(PN_CONNECTION_LOCAL_OPEN, "on_connection_local_open")
    CONNECTION_LOCAL_CLOSE = _core(PN_CONNECTION_LOCAL_CLOSE, "on_connection_local_close")
    CONNECTION_REMOTE_OPEN = _core(PN_CONNECTION_REMOTE_OPEN, "on_connection_remote_open")