ing
This commit is contained in:
parent
205ceb6dc1
commit
f6cf23940d
39
client.go
39
client.go
|
@ -54,30 +54,27 @@ func (c *client) run() {
|
|||
hasReadTimeout := c.o.ReadTimeout > 0
|
||||
c.conn.SetReadLimit(c.o.MaxMessageSize)
|
||||
|
||||
go func() {
|
||||
defer func() {
|
||||
c.o.onDisconnected(c)
|
||||
}()
|
||||
|
||||
for {
|
||||
if hasReadTimeout {
|
||||
c.conn.SetReadDeadline(time.Now().Add(c.o.ReadTimeout))
|
||||
}
|
||||
|
||||
// messageType, data, err := c.conn.ReadMessage()
|
||||
messageType, r, err := c.conn.NextReader()
|
||||
if err != nil {
|
||||
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) {
|
||||
//c.fireError(err)
|
||||
}
|
||||
break
|
||||
} else {
|
||||
c.onMessage(messageType, r)
|
||||
}
|
||||
defer func() {
|
||||
c.o.onDisconnected(c)
|
||||
}()
|
||||
|
||||
for {
|
||||
if hasReadTimeout {
|
||||
c.conn.SetReadDeadline(time.Now().Add(c.o.ReadTimeout))
|
||||
}
|
||||
|
||||
}()
|
||||
// messageType, data, err := c.conn.ReadMessage()
|
||||
messageType, r, err := c.conn.NextReader()
|
||||
if err != nil {
|
||||
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) {
|
||||
//c.fireError(err)
|
||||
}
|
||||
break
|
||||
} else {
|
||||
c.onMessage(messageType, r)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func (c *client) onMessage(messageType int, r io.Reader) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user