forked from mirror/websocket
Improve IsUnexpectedCloseError examples
This commit is contained in:
parent
615f23bc98
commit
5434f8b69b
|
@ -25,7 +25,7 @@ func ExampleIsUnexpectedCloseError(err error, c *websocket.Conn, req *http.Reque
|
|||
messageType, p, err := c.ReadMessage()
|
||||
if err != nil {
|
||||
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) {
|
||||
log.Println("error: %v, user-agent: %v", err, req.Header.Get("User-Agent"))
|
||||
log.Printf("error: %v, user-agent: %v", err, req.Header.Get("User-Agent"))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -51,6 +51,9 @@ func (c *connection) readPump() {
|
|||
for {
|
||||
_, message, err := c.ws.ReadMessage()
|
||||
if err != nil {
|
||||
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) {
|
||||
log.Printf("error: %v", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
h.broadcast <- message
|
||||
|
|
Loading…
Reference in New Issue