| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#include <kore/kore.h> |
| 18 |
#include <kore/http.h> |
| 19 |
|
| 20 |
#include "assets.h" |
| 21 |
|
| 22 |
int page(struct http_request *); |
| 23 |
int page_ws_connect(struct http_request *); |
| 24 |
|
| 25 |
void websocket_connect(struct connection *); |
| 26 |
void websocket_disconnect(struct connection *); |
| 27 |
void websocket_message(struct connection *, |
| 28 |
u_int8_t, void *, size_t); |
| 29 |
|
| 30 |
|
| 31 |
void |
| 32 |
websocket_connect(struct connection *c) |
| 33 |
{ |
| 34 |
kore_log(LOG_NOTICE, "%p: connected", c); |
| 35 |
} |
| 36 |
|
| 37 |
void |
| 38 |
websocket_message(struct connection *c, u_int8_t op, void *data, size_t len) |
| 39 |
{ |
| 40 |
kore_websocket_broadcast(c, op, data, len, WEBSOCKET_BROADCAST_GLOBAL); |
| 41 |
} |
| 42 |
|
| 43 |
void |
| 44 |
websocket_disconnect(struct connection *c) |
| 45 |
{ |
| 46 |
kore_log(LOG_NOTICE, "%p: disconnecting", c); |
| 47 |
} |
| 48 |
|
| 49 |
int |
| 50 |
page(struct http_request *req) |
| 51 |
{ |
| 52 |
http_response_header(req, "content-type", "text/html"); |
| 53 |
http_response(req, 200, asset_frontend_html, asset_len_frontend_html); |
| 54 |
|
| 55 |
return (KORE_RESULT_OK); |
| 56 |
} |
| 57 |
|
| 58 |
int |
| 59 |
page_ws_connect(struct http_request *req) |
| 60 |
{ |
| 61 |
|
| 62 |
kore_websocket_handshake(req, "websocket_connect", |
| 63 |
"websocket_message", "websocket_disconnect"); |
| 64 |
|
| 65 |
return (KORE_RESULT_OK); |
| 66 |
} |