package global import ( "errors" "eta/eta_api/utils" "strconv" "time" "github.com/gorilla/websocket" ) var MonitorMessageConn = make(map[int]*websocket.Conn) var ( EDB_MONITOR_MESSAGE_CONNECT_CACHE = "edb_monitor_message_cache:" ) func EdbMonitorMessageHealth(adminId int) (isClose bool, err error) { conn := MonitorMessageConn[adminId] if conn == nil { err = errors.New("no connection") isClose = true return } _, msg, err := conn.ReadMessage() if err != nil { isClose = true return } if string(msg) == "ping" { healthKey := EDB_MONITOR_MESSAGE_CONNECT_CACHE + strconv.Itoa(adminId) err = utils.Rc.Put(healthKey, "1", time.Minute*1) if err != nil { return } } return }