ing
This commit is contained in:
parent
8a218a0806
commit
e12a800dd3
|
@ -163,8 +163,12 @@ func handleClientRead(c *Client, conn *server.Conn, doneChan chan<- struct{}, st
|
||||||
close(doneChan)
|
close(doneChan)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
if 0 < c.MaxMessageSize {
|
||||||
conn.SetReadLimit(c.MaxMessageSize)
|
conn.SetReadLimit(c.MaxMessageSize)
|
||||||
|
}
|
||||||
|
if 0 < c.ReadTimeout {
|
||||||
conn.SetReadDeadline(time.Now().Add(c.ReadTimeout))
|
conn.SetReadDeadline(time.Now().Add(c.ReadTimeout))
|
||||||
|
}
|
||||||
conn.SetPongHandler(func(string) error {
|
conn.SetPongHandler(func(string) error {
|
||||||
conn.SetReadDeadline(time.Now().Add(c.PongTimeout))
|
conn.SetReadDeadline(time.Now().Add(c.PongTimeout))
|
||||||
return nil
|
return nil
|
||||||
|
@ -220,7 +224,9 @@ func handleClientWrite(c *Client, conn *server.Conn, doneChan chan<- struct{}, s
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case message, ok := <-c.writeChan:
|
case message, ok := <-c.writeChan:
|
||||||
|
if 0 < c.WriteTimeout {
|
||||||
conn.SetWriteDeadline(time.Now().Add(c.WriteTimeout))
|
conn.SetWriteDeadline(time.Now().Add(c.WriteTimeout))
|
||||||
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
conn.WriteMessage(server.CloseMessage, []byte{})
|
conn.WriteMessage(server.CloseMessage, []byte{})
|
||||||
return
|
return
|
||||||
|
|
|
@ -236,8 +236,12 @@ func handleRead(s *Server, conn *server.Conn, doneChan chan<- struct{}, stopChan
|
||||||
close(doneChan)
|
close(doneChan)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
if 0 < s.ServerHandler.GetMaxMessageSize() {
|
||||||
conn.SetReadLimit(s.ServerHandler.GetMaxMessageSize())
|
conn.SetReadLimit(s.ServerHandler.GetMaxMessageSize())
|
||||||
|
}
|
||||||
|
if 0 < s.ServerHandler.GetReadTimeout() {
|
||||||
conn.SetReadDeadline(time.Now().Add(s.ServerHandler.GetReadTimeout()))
|
conn.SetReadDeadline(time.Now().Add(s.ServerHandler.GetReadTimeout()))
|
||||||
|
}
|
||||||
conn.SetPongHandler(func(string) error {
|
conn.SetPongHandler(func(string) error {
|
||||||
conn.SetReadDeadline(time.Now().Add(s.ServerHandler.GetPongTimeout()))
|
conn.SetReadDeadline(time.Now().Add(s.ServerHandler.GetPongTimeout()))
|
||||||
return nil
|
return nil
|
||||||
|
@ -293,7 +297,9 @@ func handleWrite(s *Server, conn *server.Conn, doneChan chan<- struct{}, stopCha
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case message, ok := <-writeChan:
|
case message, ok := <-writeChan:
|
||||||
|
if 0 < s.ServerHandler.GetWriteTimeout() {
|
||||||
conn.SetWriteDeadline(time.Now().Add(s.ServerHandler.GetWriteTimeout()))
|
conn.SetWriteDeadline(time.Now().Add(s.ServerHandler.GetWriteTimeout()))
|
||||||
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
conn.WriteMessage(server.CloseMessage, []byte{})
|
conn.WriteMessage(server.CloseMessage, []byte{})
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user