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

Function ws_ping

app/wizard/tmpl/http/websocket.cpp:4–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include "websocket.h"
3
4static bool ws_ping(acl::websocket& in, acl::websocket& out)
5{
6 unsigned long long len = in.get_frame_payload_len();
7 if (len == 0) {
8 if (out.send_frame_pong((const void*) NULL, 0) == false) {
9 return false;
10 } else {
11 return true;
12 }
13 }
14
15 out.reset().set_frame_fin(true)
16 .set_frame_opcode(acl::FRAME_PONG)
17 .set_frame_payload_len(len);
18
19 char buf[4096];
20 while (true) {
21 int ret = in.read_frame_data(buf, sizeof(buf) - 1);
22 if (ret == 0) {
23 break;
24 }
25
26 if (ret < 0) {
27 printf("read_frame_data error\r\n");
28 return false;
29 }
30
31 buf[ret] = 0;
32 printf("read: [%s]\r\n", buf);
33 if (out.send_frame_data(buf, ret) == false) {
34 printf("send_frame_data error\r\n");
35 return false;
36 }
37 }
38
39 return true;
40}
41
42static bool ws_pong(acl::websocket& in, acl::websocket&)
43{

Callers 1

websocket_runFunction · 0.85

Calls 4

send_frame_pongMethod · 0.80
read_frame_dataMethod · 0.80
send_frame_dataMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…