| 1 |
// Copyright (c) Microsoft. All rights reserved. |
| 2 |
// Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 3 |
|
| 4 |
#ifndef MESSAGE_SENDER_H |
| 5 |
#define MESSAGE_SENDER_H |
| 6 |
|
| 7 |
#include <stdbool.h> |
| 8 |
#include "azure_uamqp_c/link.h" |
| 9 |
#include "azure_uamqp_c/message.h" |
| 10 |
#include "azure_c_shared_utility/xlogging.h" |
| 11 |
#include "azure_uamqp_c/async_operation.h" |
| 12 |
#include "azure_c_shared_utility/tickcounter.h" |
| 13 |
#include "umock_c/umock_c_prod.h" |
| 14 |
#include "azure_macro_utils/macro_utils.h" |
| 15 |
|
| 16 |
#ifdef __cplusplus |
| 17 |
extern "C" { |
| 18 |
#endif /* __cplusplus */ |
| 19 |
|
| 20 |
#define MESSAGE_SEND_RESULT_VALUES \ |
| 21 |
MESSAGE_SEND_OK, \ |
| 22 |
MESSAGE_SEND_ERROR, \ |
| 23 |
MESSAGE_SEND_TIMEOUT, \ |
| 24 |
MESSAGE_SEND_CANCELLED |
| 25 |
|
| 26 |
MU_DEFINE_ENUM(MESSAGE_SEND_RESULT, MESSAGE_SEND_RESULT_VALUES) |
| 27 |
|
| 28 |
#define MESSAGE_SENDER_STATE_VALUES \ |
| 29 |
MESSAGE_SENDER_STATE_IDLE, \ |
| 30 |
MESSAGE_SENDER_STATE_OPENING, \ |
| 31 |
MESSAGE_SENDER_STATE_OPEN, \ |
| 32 |
MESSAGE_SENDER_STATE_CLOSING, \ |
| 33 |
MESSAGE_SENDER_STATE_ERROR |
| 34 |
|
| 35 |
MU_DEFINE_ENUM(MESSAGE_SENDER_STATE, MESSAGE_SENDER_STATE_VALUES) |
| 36 |
|
| 37 |
typedef struct MESSAGE_SENDER_INSTANCE_TAG* MESSAGE_SENDER_HANDLE; |
| 38 |
typedef void(*ON_MESSAGE_SEND_COMPLETE)(void* context, MESSAGE_SEND_RESULT send_result, AMQP_VALUE delivery_state); |
| 39 |
typedef void(*ON_MESSAGE_SENDER_STATE_CHANGED)(void* context, MESSAGE_SENDER_STATE new_state, MESSAGE_SENDER_STATE previous_state); |
| 40 |
|
| 41 |
MOCKABLE_FUNCTION(, MESSAGE_SENDER_HANDLE, messagesender_create, LINK_HANDLE, link, ON_MESSAGE_SENDER_STATE_CHANGED, on_message_sender_state_changed, void*, context); |
| 42 |
MOCKABLE_FUNCTION(, void, messagesender_destroy, MESSAGE_SENDER_HANDLE, message_sender); |
| 43 |
MOCKABLE_FUNCTION(, int, messagesender_open, MESSAGE_SENDER_HANDLE, message_sender); |
| 44 |
MOCKABLE_FUNCTION(, int, messagesender_close, MESSAGE_SENDER_HANDLE, message_sender); |
| 45 |
MOCKABLE_FUNCTION(, ASYNC_OPERATION_HANDLE, messagesender_send_async, MESSAGE_SENDER_HANDLE, message_sender, MESSAGE_HANDLE, message, ON_MESSAGE_SEND_COMPLETE, on_message_send_complete, void*, callback_context, tickcounter_ms_t, timeout); |
| 46 |
MOCKABLE_FUNCTION(, void, messagesender_set_trace, MESSAGE_SENDER_HANDLE, message_sender, bool, traceOn); |
| 47 |
|
| 48 |
#ifdef __cplusplus |
| 49 |
} |
| 50 |
#endif /* __cplusplus */ |
| 51 |
|
| 52 |
#endif /* MESSAGE_SENDER_H */ |