From 57065b83df28ede14f179ea2c246e9e7c49bcbf9 Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 13 Apr 2018 18:45:24 +0900 Subject: [PATCH] ing --- socket/readwrite.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/socket/readwrite.go b/socket/readwrite.go index 420f264..a762798 100644 --- a/socket/readwrite.go +++ b/socket/readwrite.go @@ -16,12 +16,9 @@ func connReadHandler(readWriteHandler ReadWriteHandler, conn Conn, stopChan <-ch doneChan <- err }() - if 0 < readWriteHandler.GetMaxMessageSize() { - conn.SetReadLimit(readWriteHandler.GetMaxMessageSize()) - } - if 0 < readWriteHandler.GetReadTimeout() { - conn.SetReadDeadline(time.Now().Add(readWriteHandler.GetReadTimeout())) - } + conn.SetReadLimit(readWriteHandler.GetMaxMessageSize()) + conn.SetReadDeadline(time.Now().Add(readWriteHandler.GetReadTimeout())) + conn.SetPongHandler(func(string) error { conn.SetReadDeadline(time.Now().Add(readWriteHandler.GetPongTimeout())) return nil @@ -72,9 +69,7 @@ func connWriteHandler(readWriteHandler ReadWriteHandler, conn Conn, stopChan <-c for { select { case message, ok = <-writeChan: - if 0 < readWriteHandler.GetWriteTimeout() { - conn.SetWriteDeadline(time.Now().Add(readWriteHandler.GetWriteTimeout())) - } + conn.SetWriteDeadline(time.Now().Add(readWriteHandler.GetWriteTimeout())) if !ok { conn.WriteMessage(CloseMessage, []byte{}) return