File: client_impl_shared.h

package info (click to toggle)
aws-crt-python 0.28.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,428 kB
  • sloc: ansic: 437,955; python: 27,657; makefile: 5,855; sh: 4,289; ruby: 208; java: 82; perl: 73; cpp: 25; xml: 11
file content (147 lines) | stat: -rw-r--r-- 5,152 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#ifndef AWS_MQTT_PRIVATE_CLIENT_IMPL_SHARED_H
#define AWS_MQTT_PRIVATE_CLIENT_IMPL_SHARED_H

/**
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

#include <aws/mqtt/client.h>

struct aws_mqtt_client_connection;

/*
 * Internal enum that indicates what type of struct the underlying impl pointer actually is.  We use this
 * to safely interact with private APIs on the implementation or extract the adapted 5 client directly, as
 * necessary.
 */
enum aws_mqtt311_impl_type {

    /* 311 connection impl can be cast to `struct aws_mqtt_client_connection_311_impl` */
    AWS_MQTT311_IT_311_CONNECTION,

    /* 311 connection impl can be cast to `struct aws_mqtt_client_connection_5_impl`*/
    AWS_MQTT311_IT_5_ADAPTER,
};

struct aws_mqtt_client_connection_vtable {

    struct aws_mqtt_client_connection *(*acquire_fn)(void *impl);

    void (*release_fn)(void *impl);

    int (*set_will_fn)(
        void *impl,
        const struct aws_byte_cursor *topic,
        enum aws_mqtt_qos qos,
        bool retain,
        const struct aws_byte_cursor *payload);

    int (*set_login_fn)(void *impl, const struct aws_byte_cursor *username, const struct aws_byte_cursor *password);

    int (*use_websockets_fn)(
        void *impl,
        aws_mqtt_transform_websocket_handshake_fn *transformer,
        void *transformer_ud,
        aws_mqtt_validate_websocket_handshake_fn *validator,
        void *validator_ud);

    int (*set_http_proxy_options_fn)(void *impl, struct aws_http_proxy_options *proxy_options);

    int (*set_host_resolution_options_fn)(void *impl, const struct aws_host_resolution_config *host_resolution_config);

    int (*set_reconnect_timeout_fn)(void *impl, uint64_t min_timeout, uint64_t max_timeout);

    int (*set_connection_interruption_handlers_fn)(
        void *impl,
        aws_mqtt_client_on_connection_interrupted_fn *on_interrupted,
        void *on_interrupted_ud,
        aws_mqtt_client_on_connection_resumed_fn *on_resumed,
        void *on_resumed_ud);

    int (*set_connection_result_handlers)(
        void *impl,
        aws_mqtt_client_on_connection_success_fn *on_connection_success,
        void *on_connection_success_ud,
        aws_mqtt_client_on_connection_failure_fn *on_connection_failure,
        void *on_connection_failure_ud);

    int (*set_connection_closed_handler_fn)(
        void *impl,
        aws_mqtt_client_on_connection_closed_fn *on_closed,
        void *on_closed_ud);

    int (*set_on_any_publish_handler_fn)(
        void *impl,
        aws_mqtt_client_publish_received_fn *on_any_publish,
        void *on_any_publish_ud);

    int (*set_connection_termination_handler_fn)(
        void *impl,
        aws_mqtt_client_on_connection_termination_fn *on_termination,
        void *on_termination_ud);

    int (*connect_fn)(void *impl, const struct aws_mqtt_connection_options *connection_options);

    int (*reconnect_fn)(void *impl, aws_mqtt_client_on_connection_complete_fn *on_connection_complete, void *userdata);

    int (*disconnect_fn)(void *impl, aws_mqtt_client_on_disconnect_fn *on_disconnect, void *userdata);

    uint16_t (*subscribe_multiple_fn)(
        void *impl,
        const struct aws_array_list *topic_filters,
        aws_mqtt_suback_multi_fn *on_suback,
        void *on_suback_ud);

    uint16_t (*subscribe_fn)(
        void *impl,
        const struct aws_byte_cursor *topic_filter,
        enum aws_mqtt_qos qos,
        aws_mqtt_client_publish_received_fn *on_publish,
        void *on_publish_ud,
        aws_mqtt_userdata_cleanup_fn *on_ud_cleanup,
        aws_mqtt_suback_fn *on_suback,
        void *on_suback_ud);

    uint16_t (*resubscribe_existing_topics_fn)(void *impl, aws_mqtt_suback_multi_fn *on_suback, void *on_suback_ud);

    uint16_t (*unsubscribe_fn)(
        void *impl,
        const struct aws_byte_cursor *topic_filter,
        aws_mqtt_op_complete_fn *on_unsuback,
        void *on_unsuback_ud);

    uint16_t (*publish_fn)(
        void *impl,
        const struct aws_byte_cursor *topic,
        enum aws_mqtt_qos qos,
        bool retain,
        const struct aws_byte_cursor *payload,
        aws_mqtt_op_complete_fn *on_complete,
        void *userdata);

    int (*get_stats_fn)(void *impl, struct aws_mqtt_connection_operation_statistics *stats);

    enum aws_mqtt311_impl_type (*get_impl_type)(const void *impl);

    struct aws_event_loop *(*get_event_loop)(const void *impl);
};

struct aws_mqtt_client_connection {
    struct aws_mqtt_client_connection_vtable *vtable;
    void *impl;
};

AWS_MQTT_API enum aws_mqtt311_impl_type aws_mqtt_client_connection_get_impl_type(
    const struct aws_mqtt_client_connection *connection);

AWS_MQTT_API uint64_t aws_mqtt_hash_uint16_t(const void *item);

AWS_MQTT_API bool aws_mqtt_compare_uint16_t_eq(const void *a, const void *b);

AWS_MQTT_API bool aws_mqtt_byte_cursor_hash_equality(const void *a, const void *b);

AWS_MQTT_API struct aws_event_loop *aws_mqtt_client_connection_get_event_loop(
    const struct aws_mqtt_client_connection *connection);

#endif /* AWS_MQTT_PRIVATE_CLIENT_IMPL_SHARED_H */