302 |
302 |
303 /* ------------------------------ public API ------------------------------*/ |
303 /* ------------------------------ public API ------------------------------*/ |
304 |
304 |
305 NSAPI_PUBLIC int websocket_send_text(SYS_NETFD csd, char *msg, size_t len) { |
305 NSAPI_PUBLIC int websocket_send_text(SYS_NETFD csd, char *msg, size_t len) { |
306 char frame[WS_FRAMEHEADER_BUFLEN]; |
306 char frame[WS_FRAMEHEADER_BUFLEN]; |
307 frame[0] = 0b10000001; |
307 frame[0] = 129; // 0b10000001 |
308 size_t hlen; |
308 size_t hlen; |
309 if(len < 126) { |
309 if(len < 126) { |
310 frame[1] = (char)len; |
310 frame[1] = (char)len; |
311 hlen = 2; |
311 hlen = 2; |
312 } else if(len < 65536) { |
312 } else if(len < 65536) { |