MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / reportTrigger

Function reportTrigger

modules/io/socket/lin/tcp.c:469–497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

467}
468
469void reportTrigger(TCP tcp)
470{
471 xsMachine *the = tcp->the;
472 uint8_t triggered = tcp->triggered;
473
474 tcp->triggered = 0;
475
476 if ((triggered & kTCPWritable) && tcp->bytesWritable && !tcp->error) {
477 xsBeginHost(the);
478 xsmcSetInteger(xsResult, tcp->bytesWritable);
479 xsCallFunction1(xsReference(tcp->onWritable), tcp->obj, xsResult);
480 xsEndHost(the);
481 }
482
483 if ((triggered & kTCPReadable) && tcp->bytesReadable) {
484 xsBeginHost(the);
485 xsmcSetInteger(xsResult, tcp->bytesReadable);
486 xsCallFunction1(xsReference(tcp->onReadable), tcp->obj, xsResult);
487 xsEndHost(the);
488 }
489
490 if (triggered & kTCPError) {
491 xsBeginHost(the);
492 xsCallFunction0(xsReference(tcp->onError), tcp->obj);
493 xsEndHost(the);
494 }
495
496 tcpRelease(tcp);
497}
498
499void tcpTrigger(TCP tcp, uint8_t trigger)
500{

Callers 1

tcpTaskFunction · 0.70

Calls 1

tcpReleaseFunction · 0.70

Tested by

no test coverage detected