| 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_RECEIVER_H |
| 5 |
#define MESSAGE_RECEIVER_H |
| 6 |
|
| 7 |
#include "azure_uamqp_c/link.h" |
| 8 |
#include "azure_uamqp_c/message.h" |
| 9 |
#include "azure_uamqp_c/amqp_definitions_delivery_number.h" |
| 10 |
#include "umock_c/umock_c_prod.h" |
| 11 |
#include "azure_macro_utils/macro_utils.h" |
| 12 |
|
| 13 |
#ifdef __cplusplus |
| 14 |
extern "C" { |
| 15 |
#else |
| 16 |
#include <stdbool.h> |
| 17 |
#endif /* __cplusplus */ |
| 18 |
|
| 19 |
#define MESSAGE_RECEIVER_STATE_VALUES \ |
| 20 |
MESSAGE_RECEIVER_STATE_IDLE, \ |
| 21 |
MESSAGE_RECEIVER_STATE_OPENING, \ |
| 22 |
MESSAGE_RECEIVER_STATE_OPEN, \ |
| 23 |
MESSAGE_RECEIVER_STATE_CLOSING, \ |
| 24 |
MESSAGE_RECEIVER_STATE_ERROR |
| 25 |
|
| 26 |
MU_DEFINE_ENUM(MESSAGE_RECEIVER_STATE, MESSAGE_RECEIVER_STATE_VALUES) |
| 27 |
|
| 28 |
typedef struct MESSAGE_RECEIVER_INSTANCE_TAG* MESSAGE_RECEIVER_HANDLE; |
| 29 |
typedef AMQP_VALUE (*ON_MESSAGE_RECEIVED)(const void* context, MESSAGE_HANDLE message); |
| 30 |
typedef void(*ON_MESSAGE_RECEIVER_STATE_CHANGED)(const void* context, MESSAGE_RECEIVER_STATE new_state, MESSAGE_RECEIVER_STATE previous_state); |
| 31 |
|
| 32 |
MOCKABLE_FUNCTION(, MESSAGE_RECEIVER_HANDLE, messagereceiver_create, LINK_HANDLE, link, ON_MESSAGE_RECEIVER_STATE_CHANGED, on_message_receiver_state_changed, void*, context); |
| 33 |
MOCKABLE_FUNCTION(, void, messagereceiver_destroy, MESSAGE_RECEIVER_HANDLE, message_receiver); |
| 34 |
MOCKABLE_FUNCTION(, int, messagereceiver_open, MESSAGE_RECEIVER_HANDLE, message_receiver, ON_MESSAGE_RECEIVED, on_message_received, void*, callback_context); |
| 35 |
MOCKABLE_FUNCTION(, int, messagereceiver_close, MESSAGE_RECEIVER_HANDLE, message_receiver); |
| 36 |
MOCKABLE_FUNCTION(, int, messagereceiver_get_link_name, MESSAGE_RECEIVER_HANDLE, message_receiver, const char**, link_name); |
| 37 |
MOCKABLE_FUNCTION(, int, messagereceiver_get_received_message_id, MESSAGE_RECEIVER_HANDLE, message_receiver, delivery_number*, message_number); |
| 38 |
MOCKABLE_FUNCTION(, int, messagereceiver_send_message_disposition, MESSAGE_RECEIVER_HANDLE, message_receiver, const char*, link_name, delivery_number, message_number, AMQP_VALUE, delivery_state); |
| 39 |
MOCKABLE_FUNCTION(, void, messagereceiver_set_trace, MESSAGE_RECEIVER_HANDLE, message_receiver, bool, trace_on); |
| 40 |
|
| 41 |
#ifdef __cplusplus |
| 42 |
} |
| 43 |
#endif /* __cplusplus */ |
| 44 |
|
| 45 |
#endif /* MESSAGE_RECEIVER_H */ |