-
Notifications
You must be signed in to change notification settings - Fork 9
/
cdata.h
63 lines (51 loc) · 1.85 KB
/
cdata.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
/* Asynchronous SSE Server
* Author: Peter Deak ([email protected])
* License: GPL
*/
#ifndef HASSES_CDATA_H
#define HASSES_CDATA_H
#include <time.h>
#define STATUS_UNKNOWN 0
#define STATUS_NEW 1 //New connection, no communication yet
#define STATUS_SSLACPT 2 //Under ssl accept SSL_accept() needs read or write
#define STATUS_HEADER 3 //Processing http header parts, no special encoding yet
#define STATUS_COMM 4 //Http handshake done, http chunked encoding
#define STATUS_END 5 //Communication terminated
struct CliSubsribe
{
char token[32];
struct CliSubsribe *next;
};
struct CliConn
{
int descr; //socket descriptor
void *cio; //cio stuff
char info[64]; //ip & port
char agent[192]; //user agent
char err; //Error status
time_t created; //Creation time (reset on reinit) TTL wokrs on this.
time_t firstc; //First connection time
int status; //Connection status
struct CliSubsribe *subs; //Tokens of subscribes
int allsubs; //Listening on all token if this 1
int message; //message count
int reinit; //reinit count
char uniq_id[64]; //unique client id (optional) Can be set by parameter "id"
};
int client_init(void);
int client_start(void);
struct CliConn * client_current(void);
struct CliConn * client_next(void);
struct CliConn * client_get(int descr);
struct CliConn * client_add(int descr);
int client_del(int descr);
int client_count(void);
int subscribed_client_count(char *sub_to_search);
int client_count_commstate(void);
void client_list(int level);
void client_subscribe_add (struct CliConn *cli,char *ss);
int client_subscribe_exists(struct CliConn *cli,char *ss,int mmatch,char *rejectId);
void client_subscribe_clear (struct CliConn *cli);
void client_subscribe_list (struct CliConn *cli,char *sbuf,int max);
#endif
//end code.