| 65 | |
| 66 | |
| 67 | void on_link_flow(messaging_handler& handler, pn_event_t* event) { |
| 68 | pn_link_t *lnk = pn_event_link(event); |
| 69 | // TODO: process session flow data, if no link-specific data, just return. |
| 70 | if (!lnk) return; |
| 71 | int state = pn_link_state(lnk); |
| 72 | if ((state&PN_LOCAL_ACTIVE) && (state&PN_REMOTE_ACTIVE)) { |
| 73 | link_context& lctx = link_context::get(lnk); |
| 74 | if (pn_link_is_sender(lnk)) { |
| 75 | if (pn_link_credit(lnk) > 0) { |
| 76 | sender s(make_wrapper<sender>(lnk)); |
| 77 | bool draining = pn_link_get_drain(lnk); |
| 78 | if ( draining && !lctx.draining) { |
| 79 | handler.on_sender_drain_start(s); |
| 80 | } |
| 81 | lctx.draining = draining; |
| 82 | // create on_message extended event |
| 83 | handler.on_sendable(s); |
| 84 | } |
| 85 | } else { |
| 86 | // receiver |
| 87 | if (!pn_link_credit(lnk) && lctx.draining) { |
| 88 | lctx.draining = false; |
| 89 | pn_link_set_drain(lnk, false); |
| 90 | receiver r(make_wrapper<receiver>(lnk)); |
| 91 | handler.on_receiver_drain_finish(r); |
| 92 | } |
| 93 | credit_topup(lnk); |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | // Decode the message corresponding to a delivery from a link. |
| 99 | void message_decode(message& msg, proton::delivery delivery) { |
no test coverage detected