MCPcopy Create free account
hub / github.com/caozhiyi/CppNet / OnMessage

Method OnMessage

test/http/HttpServer.cpp:28–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28void CHttpServer::OnMessage(const cppnet::Handle& handle, base::CBuffer* data,
29 uint32_t, uint32_t err) {
30
31 if (err != CEC_SUCCESS) {
32 return;
33 }
34
35 _mutex.lock();
36 CHttpContext& context = _context_map[handle];
37 _mutex.unlock();
38
39 _time_tool.Now();
40 if (!context.ParseRequest(data, _time_tool.GetMsec())) {
41 handle->Write("HTTP/1.1 400 Bad Request\r\n\r\n", sizeof("HTTP/1.1 400 Bad Request\r\n\r\n"));
42 handle->Close();
43 }
44
45 if (context.IsGotAll()) {
46 OnRequest(handle, context.GetRequest());
47 context.Reset();
48 }
49}
50
51void CHttpServer::OnMessageSend(const cppnet::Handle& , uint32_t , uint32_t ) {
52 // do nothing.

Callers

nothing calls this directly

Calls 8

OnRequestFunction · 0.85
NowMethod · 0.80
ParseRequestMethod · 0.80
GetMsecMethod · 0.80
CloseMethod · 0.80
IsGotAllMethod · 0.80
WriteMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected