Giter VIP home page Giter VIP logo

Comments (3)

House-Men avatar House-Men commented on June 15, 2024

补充一个问题:在使用WebSocketServer时虽然能够通过onopen与onclose实现监控ws会话数,但无法监控父类HttpServer的实际当前tcp连接数,目前还在理解源代码看从哪里着手增加这个监控连接数的功能,也期望作者后面能支持下这个需求。

from libhv.

House-Men avatar House-Men commented on June 15, 2024

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.

ithewei avatar ithewei commented on June 15, 2024

首先,感谢你的反馈以及对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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.