github.com/gorilla/websocket 如何知道客户端断开连接?

iamlgz · · 2218 次点击
czyt
云在青天水在瓶
``` // IsCloseError returns boolean indicating whether the error is a *CloseError // with one of the specified codes. func IsCloseError(err error, codes ...int) bool { if e, ok := err.(*CloseError); ok { for _, code := range codes { if e.Code == code { return true } } } return false } ``` 可以点进去看看 https://sourcegraph.com/github.com/gorilla/websocket@master/-/blob/conn_test.go#L621
#1