fix
This commit is contained in:
@@ -32,6 +32,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/api/websocket/close_websocket",
|
||||
Handler: CloseWebsocketHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/api/websocket/get_stat",
|
||||
Handler: GetStatHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -321,15 +321,7 @@ func (w *wsConnectItem) heartbeat() {
|
||||
if w.debug != nil && w.debug.Exp != nil && *w.debug.Exp < time.Now().UTC().Unix() {
|
||||
w.debug = nil
|
||||
}
|
||||
//发送心跳信息
|
||||
var d interface{}
|
||||
if w.debug != nil {
|
||||
d = websocket_data.HeartBeatMsg{
|
||||
WsCount: currentWebsocketConnectCount,
|
||||
CombineCount: currentRequestCombineApiCount,
|
||||
}
|
||||
}
|
||||
if err := w.conn.WriteMessage(websocket.PongMessage, w.respondDataFormat(constants.WEBSOCKET_HEARTBEAT, d)); err != nil {
|
||||
if err := w.conn.WriteMessage(websocket.PongMessage, nil); err != nil {
|
||||
logx.Error("发送心跳信息异常,关闭连接:", w.uniqueId, err)
|
||||
w.close()
|
||||
return
|
||||
|
||||
@@ -29,6 +29,15 @@ type CloseWebsocketReq struct {
|
||||
Wid string `json:"wid"`
|
||||
}
|
||||
|
||||
type GetStatReq struct {
|
||||
Password string `form:"password"`
|
||||
}
|
||||
|
||||
type GetStatRsp struct {
|
||||
WsTotalCount int `json:"ws_total_count"` //ws连接数
|
||||
CurRequestCombineCount int `json:"cur_request_combine_count"`
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user