feat: 增加链路统计信息,两个链路分别显示在前端,D向A汇报D与B的信息
This commit is contained in:
@@ -88,27 +88,52 @@ static PyObject *build_stats_dict(const omnisocket_session_stats_t *stats) {
|
||||
}
|
||||
|
||||
static PyObject *build_kcp_stats_dict(const omnisocket_session_kcp_stats_t *stats) {
|
||||
return Py_BuildValue(
|
||||
"{s:i,s:I,s:I,s:i,s:i,s:I,s:I,s:I,s:I}",
|
||||
"connected",
|
||||
stats->connected,
|
||||
"conv",
|
||||
stats->conv,
|
||||
"rto_ms",
|
||||
stats->rto_ms,
|
||||
"srtt_ms",
|
||||
stats->srtt_ms,
|
||||
"srttvar_ms",
|
||||
stats->srttvar_ms,
|
||||
"snd_queue",
|
||||
stats->snd_queue,
|
||||
"rcv_queue",
|
||||
stats->rcv_queue,
|
||||
"snd_buffer",
|
||||
stats->snd_buffer,
|
||||
"xmit_total",
|
||||
stats->xmit_total
|
||||
);
|
||||
PyObject *dict = PyDict_New();
|
||||
PyObject *value = NULL;
|
||||
|
||||
if (dict == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define SET_KCP_STAT(key, expr) \
|
||||
do { \
|
||||
value = (expr); \
|
||||
if (value == NULL) { \
|
||||
Py_DECREF(dict); \
|
||||
return NULL; \
|
||||
} \
|
||||
if (PyDict_SetItemString(dict, (key), value) != 0) { \
|
||||
Py_DECREF(value); \
|
||||
Py_DECREF(dict); \
|
||||
return NULL; \
|
||||
} \
|
||||
Py_DECREF(value); \
|
||||
value = NULL; \
|
||||
} while (0)
|
||||
|
||||
SET_KCP_STAT("connected", PyLong_FromLong(stats->connected));
|
||||
SET_KCP_STAT("conv", PyLong_FromUnsignedLong(stats->conv));
|
||||
SET_KCP_STAT("rto_ms", PyLong_FromUnsignedLong(stats->rto_ms));
|
||||
SET_KCP_STAT("srtt_ms", PyLong_FromLong(stats->srtt_ms));
|
||||
SET_KCP_STAT("srttvar_ms", PyLong_FromLong(stats->srttvar_ms));
|
||||
SET_KCP_STAT("snd_wnd", PyLong_FromUnsignedLong(stats->snd_wnd));
|
||||
SET_KCP_STAT("rmt_wnd", PyLong_FromUnsignedLong(stats->rmt_wnd));
|
||||
SET_KCP_STAT("inflight", PyLong_FromUnsignedLong(stats->inflight));
|
||||
SET_KCP_STAT("window_limit", PyLong_FromUnsignedLong(stats->window_limit));
|
||||
SET_KCP_STAT("window_pressure_pct", PyFloat_FromDouble(stats->window_pressure_pct));
|
||||
SET_KCP_STAT("snd_queue", PyLong_FromUnsignedLong(stats->snd_queue));
|
||||
SET_KCP_STAT("rcv_queue", PyLong_FromUnsignedLong(stats->rcv_queue));
|
||||
SET_KCP_STAT("snd_buffer", PyLong_FromUnsignedLong(stats->snd_buffer));
|
||||
SET_KCP_STAT("out_segs_total", PyLong_FromUnsignedLongLong((unsigned long long) stats->out_segs_total));
|
||||
SET_KCP_STAT("retrans_total", PyLong_FromUnsignedLongLong((unsigned long long) stats->retrans_total));
|
||||
SET_KCP_STAT("fast_retrans_total", PyLong_FromUnsignedLongLong((unsigned long long) stats->fast_retrans_total));
|
||||
SET_KCP_STAT("lost_total", PyLong_FromUnsignedLongLong((unsigned long long) stats->lost_total));
|
||||
SET_KCP_STAT("repeat_total", PyLong_FromUnsignedLongLong((unsigned long long) stats->repeat_total));
|
||||
SET_KCP_STAT("xmit_total", PyLong_FromUnsignedLong(stats->xmit_total));
|
||||
|
||||
#undef SET_KCP_STAT
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
static PyObject *PyOmniSession_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) {
|
||||
|
||||
Reference in New Issue
Block a user