MCPcopy Create free account
hub / github.com/acl-dev/acl / read_frame_data

Method read_frame_data

lib_acl_cpp/src/http/websocket.cpp:467–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467int websocket::read_frame_data(void* buf, size_t size)
468{
469 if (payload_nread_ >= header_.payload_len) {
470 return 0;
471 }
472
473 if (header_.payload_len < payload_nread_ + size) {
474 size = (size_t) (header_.payload_len - payload_nread_);
475 }
476
477 int ret = client_.read(buf, size, false);
478 if (ret == -1) {
479 if (last_error() != ACL_ETIMEDOUT) {
480 logger_error("read frame data error: %d, %s",
481 last_error(), last_serror());
482 }
483 return -1;
484 }
485
486 if (header_.mask) {
487 unsigned char* mask = (unsigned char*) &header_.masking_key;
488 for (int i = 0; i < ret; i++) {
489 ((char*) buf)[i] ^= mask[(payload_nread_ + i) % 4];
490 }
491 }
492
493 payload_nread_ += ret;
494 return ret;
495}
496
497void websocket::update_head_2bytes(unsigned char ch1, unsigned ch2)
498{

Callers 15

doPingMethod · 0.80
doPongMethod · 0.80
getFilenameMethod · 0.80
getFilesizeMethod · 0.80
saveFileMethod · 0.80
read_replyFunction · 0.80
doPingMethod · 0.80
doPongMethod · 0.80
doMsgMethod · 0.80
readPayloadMethod · 0.80
ws_pingFunction · 0.80
ws_pongFunction · 0.80

Calls 3

last_errorFunction · 0.85
last_serrorFunction · 0.50
readMethod · 0.45

Tested by

no test coverage detected