Example #1
0
void check_codec (void)
{
    flux_msg_t *msg;
    int epoch;

    ok ((msg = flux_heartbeat_encode (44000)) != NULL,
        "flux_heartbeat_encode works");
    ok (flux_heartbeat_decode (msg, &epoch) == 0 && epoch == 44000,
        "flux_heartbeat_decode works and returns encoded epoch");
    flux_msg_destroy (msg);
}
Example #2
0
static void timer_cb (flux_reactor_t *r, flux_watcher_t *w,
                      int revents, void *arg)
{
    heartbeat_t *hb = arg;
    flux_msg_t *msg = NULL;

    if (!(msg = flux_heartbeat_encode (hb->send_epoch++))) {
        log_err ("heartbeat_encode");
        goto done;
    }
    if (flux_send (hb->h, msg, 0) < 0) {
        log_err ("flux_send");
        goto done;
    }
done:
    flux_msg_destroy (msg);
}