From 2f9a8ca29b36a753d004aa9e111f18f7fc87c1fe Mon Sep 17 00:00:00 2001 From: HimbeerserverDE Date: Sat, 28 Aug 2021 14:18:56 +0200 Subject: Differentiate between timeouts and disconnects --- client_conn.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'client_conn.go') diff --git a/client_conn.go b/client_conn.go index 4be45ba..d665cc5 100644 --- a/client_conn.go +++ b/client_conn.go @@ -10,6 +10,7 @@ import ( "github.com/HimbeerserverDE/srp" "github.com/anon55555/mt" + "github.com/anon55555/mt/rudp" ) type clientState uint8 @@ -63,7 +64,12 @@ func handleClt(cc *clientConn) { pkt, err := cc.Recv() if err != nil { if errors.Is(err, net.ErrClosed) { - cc.log("<->", "disconnect") + if errors.Is(cc.WhyClosed(), rudp.ErrTimedOut) { + cc.log("<->", "timeout") + } else { + cc.log("<->", "disconnect") + } + if cc.name != "" { playersMu.Lock() delete(players, cc.name) -- cgit v1.2.3