mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-03 08:28:31 +00:00
Fix disconnect reason statistics
This commit is contained in:
parent
c42a0fb171
commit
ab14cdac72
1 changed files with 7 additions and 1 deletions
|
@ -316,7 +316,13 @@ func getDeadline() time.Time {
|
|||
|
||||
func CloseConnection(conn *websocket.Conn, closeMsg *websocket.CloseError) {
|
||||
Statistics.DisconnectCodes[strconv.Itoa(closeMsg.Code)]++
|
||||
Statistics.DisconnectReasons[closeMsg.Text]++
|
||||
closeTxt := closeMsg.Text
|
||||
if strings.Contains(closeTxt, "read: connection reset by peer") {
|
||||
closeTxt = "read: connection reset by peer"
|
||||
} else if closeMsg.Code == 1001 {
|
||||
closeTxt = "clean shutdown"
|
||||
}
|
||||
Statistics.DisconnectReasons[closeTxt]++
|
||||
|
||||
conn.WriteControl(websocket.CloseMessage, websocket.FormatCloseMessage(closeMsg.Code, closeMsg.Text), getDeadline())
|
||||
conn.Close()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue