Create a message with a map { "sequence" : number } encode it and return the encoded buffer. */
| 57 | |
| 58 | /* Create a message with a map { "sequence" : number } encode it and return the encoded buffer. */ |
| 59 | static void send_message(app_data_t* app, pn_link_t *sender) { |
| 60 | /* Construct a message with the map { "sequence": app.sent } */ |
| 61 | pn_data_t* body; |
| 62 | pn_message_clear(app->message); |
| 63 | body = pn_message_body(app->message); |
| 64 | pn_message_set_id(app->message, (pn_atom_t){.type=PN_ULONG, .u.as_ulong=app->sent}); |
| 65 | pn_data_put_map(body); |
| 66 | pn_data_enter(body); |
| 67 | pn_data_put_string(body, pn_bytes(sizeof("sequence")-1, "sequence")); |
| 68 | pn_data_put_int(body, app->sent); /* The sequence number */ |
| 69 | pn_data_exit(body); |
| 70 | if (pn_message_send(app->message, sender, &app->message_buffer) < 0) { |
| 71 | fprintf(stderr, "error sending message: %s\n", pn_error_text(pn_message_error(app->message))); |
| 72 | exit(1); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | /* Returns true to continue, false if finished */ |
| 77 | static bool handle(app_data_t* app, pn_event_t* event) { |
no test coverage detected