aboutsummaryrefslogtreecommitdiff
path: root/websocksy.h
blob: 0fc9538c649a7c47646a2fa79eeb478abf6fbfcb (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
#include <stdint.h>
#include <stdlib.h>

#define WS_MAX_LINE 16384

typedef enum {
	ws_new = 0,
	ws_http,
	ws_rfc6455
} ws_state;

struct {
	char* host;
	char* port;
	struct {
		char* name;
	} backend;
} config = {
	.host = "::",
	.port = "8001",
	.backend.name = "internal"
};

typedef struct {
	char* name;
	int fd;
} ws_proto;

typedef struct /*_web_socket*/ {
	uint8_t read_buffer[WS_MAX_LINE];
	size_t read_buffer_offset;
	ws_state state;

	int fd;
	size_t protocols;
	ws_proto* protocol;
} websocket;