Skip to content

Commit

Permalink
usb2snes: fix websocket receiving to Discard() any remaining frames a…
Browse files Browse the repository at this point in the history
…fter parsing message body
JamesDunne committed Apr 26, 2024
1 parent f4690ca commit 9088fc6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions services/usb2snes/usb2snes.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package usb2snes
import (
"context"
"encoding/json"
"errors"
"fmt"
"github.com/gobwas/ws"
"github.com/gobwas/ws/wsutil"
@@ -786,5 +787,10 @@ serverLoop:
log.Printf("usb2snes: %s: unrecognized opcode '%s'\n", clientName, cmd.Opcode)
break
}

if err := r.Discard(); err != nil && !errors.Is(err, io.EOF) {
log.Printf("usb2snes: %s: unable to discard remainder of frame: %v\n", clientName, err)
break serverLoop
}
}
}

0 comments on commit 9088fc6

Please sign in to comment.