blob: 398450d2faf89c904883c852319668489c32fcb7 (
plain)
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
|
/*
* Created by yuuta on 7/13/22.
*/
#ifndef LIBAC_NET_H
#define LIBAC_NET_H
#include "incl.h"
#include "common.h"
#include "events.h"
#include "requests.h"
/* Connection */
typedef struct ac_connection_parameters {
char *host;
uint16_t port;
unsigned int version;
char *id;
char *token;
} ac_connection_parameters_t;
/**
* Connect to the server.
* @param parameters Connection parameters. Untouched.
* @param out Output connection reference if succeeds. Not-NULL.
* @return AC_E_OK or an error code. When failed, *out will be untouched.
* MT-Safe
*/
LIBAC_EXPORT int ac_connect(ac_connection_parameters_t parameters, void **out);
/**
* Disconnect the connection.
* @param connection A non-NULL and connected connection passed as-is from ac_connect.
* @return AC_E_OK or an error code. When failed, connection is undefined. When succeeds, connection is freed and invalid.
* MT-Unsafe
*/
LIBAC_EXPORT int ac_disconnect(void *connection);
/**
* Blocks the current thread until a new response or event arrives.
* @param connection A non-NULL and connected connection passed as-is from ac_connect.
* @param response Output response of either an event or a response. May be NULL even if it succeeds.
* @return AC_E_OK or an error code. When failed, *response is NULL.
*/
LIBAC_EXPORT int ac_receive(void *connection, ac_obj_t **response);
#endif /* LIBAC_NET_H */
|