mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 14:50:55 +00:00
fix example/chat i/o timeout
This commit is contained in:
parent
079993b9f7
commit
8c0ad5ef88
@ -54,14 +54,13 @@ func (c *connection) readPump() {
|
|||||||
}()
|
}()
|
||||||
c.ws.SetReadLimit(maxMessageSize)
|
c.ws.SetReadLimit(maxMessageSize)
|
||||||
c.ws.SetReadDeadline(time.Now().Add(readWait))
|
c.ws.SetReadDeadline(time.Now().Add(readWait))
|
||||||
|
c.ws.SetPongHandler(func(string) error { c.ws.SetReadDeadline(time.Now().Add(readWait)); return nil })
|
||||||
for {
|
for {
|
||||||
op, r, err := c.ws.NextReader()
|
op, r, err := c.ws.NextReader()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch op {
|
switch op {
|
||||||
case websocket.PongMessage:
|
|
||||||
c.ws.SetReadDeadline(time.Now().Add(readWait))
|
|
||||||
case websocket.TextMessage:
|
case websocket.TextMessage:
|
||||||
message, err := ioutil.ReadAll(r)
|
message, err := ioutil.ReadAll(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user