MCPcopy Create free account
hub / github.com/Tencent/Hardcoder / dataRecv

Method dataRecv

libapp2sys/src/main/cpp/udp.h:513–539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

511
512
513 int dataRecv(UdpPkg *udpPkg, Receiver *rs) {
514 std::pair<uint32_t, uint8_t *> *sessionPair = rs->sessionMap.count(udpPkg->sessionid) ? rs->sessionMap[udpPkg->sessionid] : NULL;
515
516 if (sessionPair == NULL && udpPkg->offset != 0) {
517 perr("Not session:%d sessionPair:%d first package offset:%u", TOINT(udpPkg->sessionid), (int) ((uint64_t)sessionPair & 0xffffffffL) , udpPkg->offset);
518 return 0;
519 }
520 if (sessionPair && udpPkg->offset != sessionPair->first) {
521 perr("session:%d offset error:%u local:%u", TOINT(udpPkg->sessionid), udpPkg->offset, sessionPair->first);
522 return 0;
523 }
524
525 if (!sessionPair) {
526 sessionPair = new std::pair<uint32_t, uint8_t *>(0, new uint8_t[udpPkg->totallen]);
527 rs->sessionMap[udpPkg->sessionid] = sessionPair;
528 }
529 memcpy(sessionPair->second + sessionPair->first, udpPkg->data, udpPkg->datalen);
530 sessionPair->first = udpPkg->offset + udpPkg->datalen;
531
532 if (sessionPair->first == udpPkg->totallen) {
533 recvEvent(EVENT_DATA, &rs->fromaddr, udpPkg->sessionid, sessionPair->second, sessionPair->first);
534 delete[] sessionPair->second;
535 delete sessionPair;
536 rs->sessionMap.erase(udpPkg->sessionid);
537 }
538 return 0;
539 }
540
541
542 int checkSendQueue() {

Callers

nothing calls this directly

Calls 2

countMethod · 0.80
eraseMethod · 0.45

Tested by

no test coverage detected