Comments (3)
补充一个问题:在使用WebSocketServer时虽然能够通过onopen与onclose实现监控ws会话数,但无法监控父类HttpServer的实际当前tcp连接数,目前还在理解源代码看从哪里着手增加这个监控连接数的功能,也期望作者后面能支持下这个需求。
from libhv.
http服务监控TCP连接断开事件已解决 测试正常 大致处理如下
//HttpServer.h的http_server_s中增加两个回调指针
std::function<bool(hio_t* io)> onAccept;
std::function<void(hio_t* io)> onClose;
//HttpHandler.h的HttpHandler中增加一个指针存储
void *user_data;
//HttpServer.cpp的on_close中增加关闭回调触发
http_server_t* server = (http_server_t*)handler->user_data;
...
if (loop) {
if (server->onClose) {
server->onClose(io);
}
--loop->connectionNum;
}
//HttpServer.cpp的on_accept中增加连接回调触发和保存指针
if (server->onAccept) {
if (!server->onAccept(io)) {
hio_close(io);
return;
}
}
++loop->connectionNum;
...
handler->user_data = server;
from libhv.
首先,感谢你的反馈以及对libhv的认可!
你上面的大多问题中是对hmain和hlog的定制化改造,如果不满足你的需要的话,可以fork后自行修改。
问题1:这个你可以提个PR
问题2:可以调整为Win32Event处理方式,只是需要sleep
问题3:可以在main_ctx_init后自行再重新设置conf/pid/log等路径
问题4:这里是调用了waitpid循环等待所有子进程退出
关于HttpServer提供出onAccept和onClose回调,这个后面可以考虑加上。
from libhv.
Related Issues (20)
- requests 超时问题 HOT 3
- 部分日志宏与wireshark重定义 HOT 1
- This is not a issue, it's just a suggestion HOT 2
- How to run `hidle_t` functionality in `EventLoop` HOT 1
- A suggestion for parsing command-line options HOT 1
- Some issues about the function main_ctx_init HOT 3
- 在windows服务模式下https无法正常建立连接的问题 HOT 2
- mqtt自动清除会话 HOT 1
- Handling WebSocketClient's WS_OPCODE_CLOSE code HOT 1
- MbedTLS Paths HOT 6
- hio_unpack_by_length_field()对length_adjustment成员的处理是否应该改成减去 HOT 2
- dtls 支持 HOT 2
- 是否支持单hloop_t侦听多个端口? HOT 1
- 能否支持国密双证书加密 HOT 1
- HttpHandler::Reset() 里面, 使用了空指针造成崩溃 HOT 3
- Segment error while parsing optional value options
- debugging mode is not supported when importing libhv through a repository in xmake HOT 2
- mqtt client存在的三个问题
- cross-compile android error HOT 1
- Cannot receive data after set jumbo frame on ubuntu HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libhv.