5 #include <libwebsockets.h>
7 // set these two according to your data
8 // rx buf size must be >= permessage-deflate rx size
9 #define MT_PROTOCOL_RX_BUFFER_SIZE 128
10 #define INPUT_LINE_LENGTH MT_PROTOCOL_RX_BUFFER_SIZE
13 #define HTTP_PORT 8080 // listen here
14 #define HTTP_ORIGIN "html" // where the html files are
16 #define HTTP_PORT 80 // listen here
17 #define HTTP_ORIGIN "/usr/share/mtserver" // where the html files are
19 #define HTTP_MOUNTPOINT "/" // mountpoint URL
20 #define HTTP_DEFAULT "index.html" // default filename
32 typedef struct ev_io_ws {
33 ev_io w; // input watcher
34 struct lws_context *context;
36 char *text; // input buffer pointer
37 char *pos; // input buffer current position pointer
40 typedef struct mt_server_t {
41 struct lws_context *context;
42 ev_io_ws fd_watcher; // input watcher
45 // init self, add it to loop and make it read data from fd
46 // return 0 on success, -1 otherwise
47 int mt_server_init(mt_server_t *self, struct ev_loop *loop, int fd);
49 // gett drunc an kil sellf
50 void mt_server_deinit(mt_server_t *self);