mirror of
https://github.com/zhaojh329/rtty.git
synced 2026-02-27 09:53:17 +08:00
Send uptime in heartbeat
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
+11
-1
@@ -26,6 +26,7 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
#include "ssl.h"
|
||||
#include "net.h"
|
||||
@@ -451,8 +452,17 @@ static void rtty_timer_cb(struct ev_loop *loop, struct ev_timer *w, int revents)
|
||||
}
|
||||
|
||||
if (now - rtty->last_heartbeat > RTTY_HEARTBEAT_INTEVAL - 1) {
|
||||
struct sysinfo info = {};
|
||||
|
||||
rtty->last_heartbeat = now;
|
||||
rtty_send_msg(rtty, MSG_TYPE_HEARTBEAT, NULL, 0);
|
||||
|
||||
sysinfo(&info);
|
||||
|
||||
buffer_put_u8(&rtty->wb, MSG_TYPE_HEARTBEAT);
|
||||
buffer_put_u16be(&rtty->wb, 16);
|
||||
buffer_put_u32be(&rtty->wb, info.uptime);
|
||||
buffer_put(&rtty->wb, 12); /* pad */
|
||||
ev_io_start(loop, &rtty->iow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user