mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-12-01 03:03:48 +00:00
wsutil: Added super verbose logs
This commit is contained in:
parent
abd5bba9c3
commit
bd1696ef65
|
@ -182,10 +182,10 @@ func startReadLoop(conn *websocket.Conn, eventCh chan<- Event) {
|
|||
return
|
||||
}
|
||||
|
||||
// Check if the error is a normal one:
|
||||
if websocket.IsCloseError(err, websocket.CloseNormalClosure) {
|
||||
return
|
||||
}
|
||||
// // Check if the error is a normal one:
|
||||
// if websocket.IsCloseError(err, websocket.CloseNormalClosure) {
|
||||
// return
|
||||
// }
|
||||
|
||||
// Unusual error; log and exit:
|
||||
eventCh <- Event{nil, errors.Wrap(err, "WS error")}
|
||||
|
|
|
@ -123,13 +123,20 @@ func (ws *Websocket) Send(b []byte) error {
|
|||
// SendCtx sends b over the Websocket with a deadline. It closes the internal
|
||||
// Websocket if the Send method errors out.
|
||||
func (ws *Websocket) SendCtx(ctx context.Context, b []byte) error {
|
||||
WSDebug("Waiting for the send rate limiter...")
|
||||
|
||||
if err := ws.SendLimiter.Wait(ctx); err != nil {
|
||||
WSDebug("Send rate limiter timed out.")
|
||||
return errors.Wrap(err, "SendLimiter failed")
|
||||
}
|
||||
|
||||
WSDebug("Send is passed the rate limiting. Waiting on mutex.")
|
||||
|
||||
ws.mutex.Lock()
|
||||
defer ws.mutex.Unlock()
|
||||
|
||||
WSDebug("Mutex lock acquired.")
|
||||
|
||||
if ws.closed {
|
||||
return ErrWebsocketClosed
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue