// encrypt and send this one packet on this pipe link_t link_direct(link_t link, lob_t inner, pipe_t pipe) { if(!link || !inner) return LOG("bad args"); if(!pipe && (!link->pipes || !(pipe = link->pipes->pipe))) return LOG("no network"); // add an outgoing cid if none set if(!lob_get_int(inner,"c")) lob_set_uint(inner,"c",e3x_exchange_cid(link->x, NULL)); pipe->send(pipe, e3x_exchange_send(link->x, inner), link); return link; }
// encrypt and send this one packet on this pipe link_t link_direct(link_t link, lob_t inner) { if(!link || !inner) return LOG("bad args"); if(!link->send_cb) { LOG_WARN("no network, dropping %s",lob_json(inner)); return NULL; } // add an outgoing cid if none set if(!lob_get_int(inner,"c")) lob_set_uint(inner,"c",e3x_exchange_cid(link->x, NULL)); lob_t outer = e3x_exchange_send(link->x, inner); lob_free(inner); return link_send(link, outer); }
// process any outgoing packets for this channel, optionally send given packet too link_t link_flush(link_t link, e3x_channel_t c3, lob_t inner) { if(!link || !c3) return LOG("bad args"); if(inner) e3x_channel_send(c3, inner); while((inner = e3x_channel_sending(c3))) { LOG("\t--> %s",lob_json(inner)); link_send(link, e3x_exchange_send(link->x, inner)); lob_free(inner); } // TODO if channel is now ended, remove from link->index return link; }