Debian Codegraph @

crt/aws-c-mqtt/include/aws/mqtt/private/v5/mqtt5_callbacks.h

raw symbols SCIP
1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #ifndef AWS_MQTT_MQTT5_CALLBACKS_H
7 #define AWS_MQTT_MQTT5_CALLBACKS_H
8
9 #include <aws/mqtt/mqtt.h>
10
11 #include <aws/common/linked_list.h>
12 #include <aws/mqtt/v5/mqtt5_client.h>
13
14 struct aws_mqtt5_callback_set;
15
16 /*
17 * An internal type for managing chains of callbacks attached to an mqtt5 client. Supports chains for
18 * lifecycle event handling and incoming publish packet handling.
19 *
20 * Assumed to be owned and used only by an MQTT5 client.
21 */
22 struct aws_mqtt5_callback_set_manager {
23 struct aws_mqtt5_client *client;
24
25 struct aws_linked_list callback_set_entries;
26
27 uint64_t next_callback_set_entry_id;
28 };
29
30 AWS_EXTERN_C_BEGIN
31
32 /*
33 * Initializes a callback set manager
34 */
35 AWS_MQTT_API
36 void aws_mqtt5_callback_set_manager_init(
37 struct aws_mqtt5_callback_set_manager *manager,
38 struct aws_mqtt5_client *client);
39
40 /*
41 * Cleans up a callback set manager.
42 *
43 * aws_mqtt5_callback_set_manager_init must have been previously called or this will crash.
44 */
45 AWS_MQTT_API
46 void aws_mqtt5_callback_set_manager_clean_up(struct aws_mqtt5_callback_set_manager *manager);
47
48 /*
49 * Adds a callback set to the front of the handler chain. Returns an integer id that can be used to selectively
50 * remove the callback set from the manager.
51 *
52 * May only be called on the client's event loop thread.
53 */
54 AWS_MQTT_API
55 uint64_t aws_mqtt5_callback_set_manager_push_front(
56 struct aws_mqtt5_callback_set_manager *manager,
57 struct aws_mqtt5_callback_set *callback_set);
58
59 /*
60 * Removes a callback set from the handler chain.
61 *
62 * May only be called on the client's event loop thread.
63 */
64 AWS_MQTT_API
65 void aws_mqtt5_callback_set_manager_remove(struct aws_mqtt5_callback_set_manager *manager, uint64_t callback_set_id);
66
67 /*
68 * Walks the handler chain for an MQTT5 client's incoming publish messages. The chain's callbacks will be invoked
69 * until either the end is reached or one of the callbacks returns true.
70 *
71 * May only be called on the client's event loop thread.
72 */
73 AWS_MQTT_API
74 void aws_mqtt5_callback_set_manager_on_publish_received(
75 struct aws_mqtt5_callback_set_manager *manager,
76 const struct aws_mqtt5_packet_publish_view *publish_view);
77
78 /*
79 * Walks the handler chain for an MQTT5 client's lifecycle events.
80 *
81 * May only be called on the client's event loop thread.
82 */
83 AWS_MQTT_API
84 void aws_mqtt5_callback_set_manager_on_lifecycle_event(
85 struct aws_mqtt5_callback_set_manager *manager,
86 const struct aws_mqtt5_client_lifecycle_event *lifecycle_event);
87
88 AWS_EXTERN_C_END
89
90 #endif /* AWS_MQTT_MQTT5_CALLBACKS_H */