-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathaoo_client.h
More file actions
245 lines (195 loc) · 8.4 KB
/
aoo_client.h
File metadata and controls
245 lines (195 loc) · 8.4 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/* Copyright (c) 2021 Christof Ressi
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
/** \file
* \brief C interface for AOO client
*/
#pragma once
#include "aoo_config.h"
#include "aoo_controls.h"
#include "aoo_defines.h"
#include "aoo_events.h"
#include "aoo_requests.h"
#include "aoo_types.h"
/** \cond DO_NOT_DOCUMENT */
struct AooSource;
struct AooSink;
typedef struct AooClient AooClient;
/** \endcond */
/** \brief create a new AOO client instance
*
* \return new AooClient instance on success; `NULL` on failure
*/
AOO_API AooClient * AOO_CALL AooClient_new(void);
/** \brief destroy AOO client */
AOO_API void AOO_CALL AooClient_free(AooClient *client);
/** \copydoc AooClient::setup() */
AOO_API AooError AOO_CALL AooClient_setup(
AooClient *client, AooClientSettings *settings);
/** \copydoc AooClient::run() */
AOO_API AooError AOO_CALL AooClient_run(
AooClient *client, AooSeconds timeout);
/** \copydoc AooClient::stop() */
AOO_API AooError AOO_CALL AooClient_stop(AooClient *client);
/** \copydoc AooClient::send() */
AOO_API AooError AOO_CALL AooClient_send(
AooClient *client, AooSeconds timeout);
/** \copydoc AooClient::receive() */
AOO_API AooError AOO_CALL AooClient_receive(
AooClient *client, AooSeconds timeout);
/** \copydoc AooClient::notify() */
AOO_API AooError AOO_CALL AooClient_notify(AooClient *client);
/** \copydoc AooClient::handlePacket() */
AOO_API AooError AOO_CALL AooClient_handlePacket(
AooClient *client, const AooByte *data, AooInt32 size,
const void *address, AooAddrSize addrlen);
/** \copydoc AooClient::sendPacket() */
AOO_API AooError AOO_CALL AooClient_sendPacket(
AooClient *client, const AooByte *data, AooInt32 size,
const void *address, AooAddrSize addrlen);
/** \copydoc AooClient::setEventHandler() */
AOO_API AooError AOO_CALL AooClient_setEventHandler(
AooClient *client, AooEventHandler fn, void *user, AooEventMode mode);
/** \copydoc AooClient::eventsAvailable() */
AOO_API AooBool AOO_CALL AooClient_eventsAvailable(AooClient *client);
/** \copydoc AooClient::pollEvents() */
AOO_API AooError AOO_CALL AooClient_pollEvents(AooClient *client);
/** \copydoc AooClient::addSource() */
AOO_API AooError AOO_CALL AooClient_addSource(
AooClient *client, struct AooSource *source);
/** \copydoc AooClient::removeSource() */
AOO_API AooError AOO_CALL AooClient_removeSource(
AooClient *client, struct AooSource *source);
/** \copydoc AooClient::addSink() */
AOO_API AooError AOO_CALL AooClient_addSink(
AooClient *client, struct AooSink *sink);
/** \copydoc AooClient::removeSink() */
AOO_API AooError AOO_CALL AooClient_removeSink(
AooClient *client, struct AooSink *sink);
/** \copydoc AooClient::connect() */
AOO_API AooError AooClient_connect(
AooClient *client, const AooClientConnect *args,
AooResponseHandler cb, void *context);
/** \copydoc AooClient::disconnect() */
AOO_API AooError AooClient_disconnect(
AooClient *client, AooResponseHandler cb, void *context);
/** \copydoc AooClient::joinGroup() */
AOO_API AooError AooClient_joinGroup(
AooClient *client, const AooClientJoinGroup *args,
AooResponseHandler cb, void *context);
/** \copydoc AooClient::leaveGroup() */
AOO_API AooError AooClient_leaveGroup(
AooClient *client, AooId group,
AooResponseHandler cb, void *context);
/** \copydoc AooClient::updateGroup() */
AOO_API AooError AOO_CALL AooClient_updateGroup(
AooClient *client,
AooId groupId, const AooData *groupMetadata,
AooResponseHandler cb, void *context);
/** \copydoc AooClient::updateUser() */
AOO_API AooError AOO_CALL AooClient_updateUser(
AooClient *client, AooId groupId,
const AooData *userMetadata,
AooResponseHandler cb, void *context);
/** \copydoc AooClient::customRequest() */
AOO_API AooError AOO_CALL AooClient_customRequest(
AooClient *client, const AooData *data, AooFlag flags,
AooResponseHandler cb, void *context);
/** \copydoc AooClient::findGroupByName() */
AOO_API AooError AOO_CALL AooClient_findGroupByName(
AooClient *client, const AooChar *groupName, AooId *groupId);
/** \copydoc AooClient::getGroupName() */
AOO_API AooError AOO_CALL AooClient_getGroupName(
AooClient *client, AooId group, AooChar *buffer, AooSize *size);
/** \copydoc AooClient::findPeerByName() */
AOO_API AooError AOO_CALL AooClient_findPeerByName(
AooClient *client, const AooChar *groupName, const AooChar *userName,
AooId *groupId, AooId *userId, void *address, AooAddrSize *addrlen);
/** \copydoc AooClient::findPeerByAddress() */
AOO_API AooError AOO_CALL AooClient_findPeerByAddress(
AooClient *client, const void *address, AooAddrSize addrlen,
AooId *groupId, AooId *userId);
/** \copydoc AooClient::getPeerName() */
AOO_API AooError AOO_CALL AooClient_getPeerName(
AooClient *client, AooId group, AooId user,
AooChar *groupNameBuffer, AooSize *groupNameSize,
AooChar *userNameBuffer, AooSize *userNameSize);
/** \copydoc AooClient::sendMessage() */
AOO_API AooError AOO_CALL AooClient_sendMessage(
AooClient *client, AooId group, AooId user,
const AooData *msg, AooNtpTime timeStamp, AooMessageFlags flags);
/** \copydoc AooClient::sendRequest() */
AOO_API AooError AOO_CALL AooClient_sendRequest(
AooClient *client, const AooRequest *request,
AooResponseHandler callback, void *user);
/** \copydoc AooClient::control */
AOO_API AooError AOO_CALL AooClient_control(
AooClient *client, AooCtl ctl, AooIntPtr index, void *data, AooSize size);
/*--------------------------------------------*/
/* type-safe control functions */
/*--------------------------------------------*/
/** \copydoc AooClient::setPacketSize() */
AOO_INLINE AooError AooClient_setPacketSize(AooClient *client, AooInt32 n)
{
return AooClient_control(client, kAooCtlSetPacketSize, 0, AOO_ARG(n));
}
/** \copydoc AooClient::getPacketSize() */
AOO_INLINE AooError AooClient_getPacketSize(AooClient *client, AooInt32 *n)
{
return AooClient_control(client, kAooCtlGetPacketSize, 0, AOO_ARG(*n));
}
/** \copydoc AooClient::setBinaryFormat() */
AOO_INLINE AooError AooClient_setBinaryFormat(AooClient *client, AooBool b)
{
return AooClient_control(client, kAooCtlSetBinaryFormat, 0, AOO_ARG(b));
}
/** \copydoc AooClient::getBinaryFormat() */
AOO_INLINE AooError AooClient_getBinaryFormat(AooClient *client, AooBool *b)
{
return AooClient_control(client, kAooCtlGetBinaryFormat, 0, AOO_ARG(*b));
}
/** \copydoc AooClient::setPeerPingSettings() */
AOO_INLINE AooError AooClient_setPeerPingSettings(
AooClient *client, const AooPingSettings *settings)
{
return AooClient_control(client, kAooCtlSetPingSettings, 0, AOO_ARG(*settings));
}
/** \copydoc AooClient::getPeerPingSettings() */
AOO_INLINE AooError AooClient_getPeerPingSettings(
AooClient *client, AooPingSettings *settings)
{
return AooClient_control(client, kAooCtlGetPingSettings, 0, AOO_ARG(*settings));
}
/** \copydoc AooClient::setServerPingSettings() */
AOO_INLINE AooError AooClient_setServerPingSettings(
AooClient *client, const AooPingSettings *settings)
{
return AooClient_control(client, kAooCtlSetPingSettings, 1, AOO_ARG(*settings));
}
/** \copydoc AooClient::getServerPingSettings() */
AOO_INLINE AooError AooClient_getServerPingSettings(
AooClient *client, AooPingSettings *settings)
{
return AooClient_control(client, kAooCtlGetPingSettings, 1, AOO_ARG(*settings));
}
/** \copydoc AooClient::addInterfaceAddress() */
AOO_INLINE AooError AooClient_addInterfaceAddress(
AooClient *client, const AooChar *address)
{
return AooClient_control(client, kAooCtlAddInterfaceAddress, (AooIntPtr)address, NULL, 0);
}
/** \copydoc AooClient::removeInterfaceAddress() */
AOO_INLINE AooError AooClient_removeInterfaceAddress(
AooClient *client, const AooChar *address)
{
return AooClient_control(client, kAooCtlRemoveInterfaceAddress, (AooIntPtr)address, NULL, 0);
}
/** \copydoc AooClient::clearInterfaceAddresses() */
AOO_INLINE AooError AooClient_clearInterfaceAddresses(AooClient *client)
{
return AooClient_control(client, kAooCtlRemoveInterfaceAddress, 0, NULL, 0);
}
/*--------------------------------------------*/
/* type-safe request functions */
/*--------------------------------------------*/
/* (empty) */