1108 // new type |
1108 // new type |
1109 typedef struct _thread_pool threadpool_t; |
1109 typedef struct _thread_pool threadpool_t; |
1110 typedef struct _threadpool_job threadpool_job; |
1110 typedef struct _threadpool_job threadpool_job; |
1111 typedef void*(*job_callback_f)(void *data); |
1111 typedef void*(*job_callback_f)(void *data); |
1112 |
1112 |
|
1113 |
|
1114 typedef struct WebSocket WebSocket; |
|
1115 typedef struct WSMessage WSMessage; |
|
1116 |
|
1117 struct WebSocket { |
|
1118 int (*on_open)(WebSocket *); |
|
1119 int (*on_error)(WebSocket *); |
|
1120 int (*on_message)(WebSocket *, WSMessage *msg); |
|
1121 int (*on_close)(WebSocket *); |
|
1122 void *userdata; |
|
1123 }; |
|
1124 |
|
1125 struct WSMessage { |
|
1126 /* |
|
1127 * message data (text or binary) |
|
1128 */ |
|
1129 char *data; |
|
1130 |
|
1131 /* |
|
1132 * data length |
|
1133 */ |
|
1134 size_t length; |
|
1135 |
|
1136 /* |
|
1137 * message type (opcode) |
|
1138 * 0x0: continuation |
|
1139 * 0x1: text |
|
1140 * 0x2: binary |
|
1141 * 0x3-7: reserved non-control frame |
|
1142 * 0x8: close |
|
1143 * 0x9: ping |
|
1144 * 0xa: pong |
|
1145 * 0xb-f: reserved control frame |
|
1146 */ |
|
1147 int type; |
|
1148 |
|
1149 /* |
|
1150 * if the message is incomplete, next points to the continuation message |
|
1151 */ |
|
1152 WSMessage *next; |
|
1153 }; |
|
1154 |
1113 /* --- End type definitions --- */ |
1155 /* --- End type definitions --- */ |
1114 |
1156 |
1115 /* --- Begin dispatch vector table definition --- */ |
1157 /* --- Begin dispatch vector table definition --- */ |
1116 /* --- End dispatch vector table definition --- */ |
1158 /* --- End dispatch vector table definition --- */ |
1117 |
1159 |
1391 NSAPI_PUBLIC void http_format_etag(Session *sn, Request *rq, char *etagp, int etaglen, off_t size, time_t mtime); |
1433 NSAPI_PUBLIC void http_format_etag(Session *sn, Request *rq, char *etagp, int etaglen, off_t size, time_t mtime); |
1392 NSAPI_PUBLIC int http_check_preconditions(Session *sn, Request *rq, struct tm *mtm, const char *etag); |
1434 NSAPI_PUBLIC int http_check_preconditions(Session *sn, Request *rq, struct tm *mtm, const char *etag); |
1393 NSAPI_PUBLIC int http_set_finfo(Session *sn, Request *rq, struct stat *finfo); |
1435 NSAPI_PUBLIC int http_set_finfo(Session *sn, Request *rq, struct stat *finfo); |
1394 |
1436 |
1395 NSAPI_PUBLIC char **http_hdrs2env(pblock *pb); |
1437 NSAPI_PUBLIC char **http_hdrs2env(pblock *pb); |
|
1438 |
|
1439 // new websocket API begin |
|
1440 |
|
1441 NSAPI_PUBLIC int http_handle_websocket(Session *sn, Request *rq, WebSocket *websocket); |
|
1442 |
|
1443 NSAPI_PUBLIC int websocket_send_text(SYS_NETFD csd, char *msg, size_t len); |
|
1444 |
|
1445 // websocket API end |
|
1446 |
1396 |
1447 |
1397 typedef void (*thrstartfunc)(void *); |
1448 typedef void (*thrstartfunc)(void *); |
1398 SYS_THREAD INTsysthread_start(int prio, int stksz, thrstartfunc fn, void *arg); |
1449 SYS_THREAD INTsysthread_start(int prio, int stksz, thrstartfunc fn, void *arg); |
1399 NSAPI_PUBLIC void INTsysthread_sleep(int milliseconds); |
1450 NSAPI_PUBLIC void INTsysthread_sleep(int milliseconds); |
1400 |
1451 |