MCPcopy Create free account
hub / github.com/cocos/cocos-engine / init

Method init

native/cocos/network/WebSocket-libwebsockets.cpp:546–565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

544class WebSocketFrame {
545public:
546 bool init(unsigned char *buf, ssize_t len) {
547 if (buf == nullptr && len > 0) {
548 return false;
549 }
550
551 if (!_data.empty()) {
552 LOGD("WebSocketFrame was initialized, should not init it again!\n");
553 return false;
554 }
555
556 _data.resize(LWS_PRE + len);
557 if (len > 0) {
558 std::copy(buf, buf + len, _data.begin() + LWS_PRE);
559 }
560
561 _payload = _data.data() + LWS_PRE;
562 _payloadLength = len;
563 _frameLength = len;
564 return true;
565 }
566
567 void update(ssize_t issued) {
568 _payloadLength -= issued;

Callers

nothing calls this directly

Calls 5

copyFunction · 0.50
emptyMethod · 0.45
resizeMethod · 0.45
beginMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected