forked from cee-studio/orca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslack-internal.h
75 lines (58 loc) · 1.82 KB
/
slack-internal.h
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
#ifndef SLACK_INTERNAL_H
#define SLACK_INTERNAL_H
#include "json-actor.h"
#include "json-actor-boxed.h"
#include "logconf.h" /* struct logconf */
#include "user-agent.h"
#include "websockets.h"
#include "orka-utils.h"
struct slack_adapter {
struct user_agent *ua;
struct slack *p_client;
};
/* ADAPTER PRIVATE FUNCTIONS */
void slack_adapter_init(struct slack_adapter *adapter, struct logconf *config, struct sized_buffer *token);
void slack_adapter_cleanup(struct slack_adapter *adapter);
void slack_adapter_run(
struct slack_adapter *adapter,
struct ua_resp_handle *resp_handle,
struct sized_buffer *req_body,
enum http_method http_method, char endpoint[], ...);
struct slack_rtm {
struct websockets *ws;
bool is_ready;
char base_url[UA_MAX_URL_LEN];
struct slack *p_client;
};
/* RTM PRIVATE FUNCTIONS */
void slack_rtm_init(struct slack_rtm *rtm, struct logconf *config);
void slack_rtm_cleanup(struct slack_rtm *rtm);
struct slack_socketmode {
struct websockets *ws;
bool is_ready;
char base_url[UA_MAX_URL_LEN];
struct { /* SLACK SOCKETMODE RESPONSE STRUCT */
struct sized_buffer payload;
char envelope_id[64];
char type[64];
bool accepts_response_payload;
} text;
struct slack *p_client;
};
/* SOCKET MODE PRIVATE FUNCTIONS */
void slack_socketmode_init(struct slack_socketmode *sm, struct logconf *config);
void slack_socketmode_cleanup(struct slack_socketmode *sm);
struct slack {
struct sized_buffer bot_token;
struct sized_buffer app_token;
struct slack_adapter adapter;
struct slack_socketmode sm;
struct slack_rtm rtm;
struct logconf config;
struct { /* CALLBACKS STRUCTURE */
idle_cb *on_idle; //trigers in every event loop iteration
idle_cb *on_hello; //triggers when connections first establishes
idle_cb *on_message;
} cbs;
};
#endif // SLACK_INTERNAL_H