1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-27 09:12:53 +00:00

wsutil: Added super verbose logs

This commit is contained in:
diamondburned 2020-11-01 09:44:02 -08:00
parent 06fbcfcfd1
commit 33eb8ef315
2 changed files with 11 additions and 4 deletions

View file

@ -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")}

View file

@ -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
}