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

Function websocket_run

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

Source from the content-addressed store, hash-verified

110}
111
112bool websocket_run(HttpRequest& req, HttpResponse&)
113{
114 acl::socket_stream& conn = req.getSocketStream();
115 acl::websocket in(conn), out(conn);
116
117 while (true) {
118 if (!in.read_frame_head()) {
119 printf("read_frame_head error\r\n");
120 return false;
121 }
122
123 bool ret;
124 unsigned char opcode = in.get_frame_opcode();
125 switch (opcode) {
126 case acl::FRAME_PING:
127 ret = ws_ping(in, out);
128 break;
129 case acl::FRAME_PONG:
130 ret = ws_pong(in, out);
131 break;
132 case acl::FRAME_CLOSE:
133 ret = ws_close(in, out);
134 break;
135 case acl::FRAME_TEXT:
136 case acl::FRAME_BINARY:
137 ret = ws_msg(in, out);
138 break;
139 case acl::FRAME_CONTINUATION:
140 ret = false;
141 printf("1-invalid opcode: 0x%x\r\n", opcode);
142 break;
143 default:
144 printf("2-invalid opcode: 0x%x\r\n", opcode);
145 ret = false;
146 break;
147 }
148
149 if (ret == false) {
150 break;
151 }
152 }
153
154 return false;
155}

Callers 3

mainFunction · 0.70
mainFunction · 0.70
mainFunction · 0.70

Calls 5

ws_pingFunction · 0.85
ws_pongFunction · 0.85
ws_closeFunction · 0.85
ws_msgFunction · 0.85
read_frame_headMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…