Better ignore message handling

This commit is contained in:
7x11x13 2024-07-12 23:38:21 -04:00
parent 723a426203
commit 56cad911af
2 changed files with 6 additions and 5 deletions

View File

@ -27,6 +27,7 @@ const (
var ignoreMessageCodes = map[uint32]bool{
7: true,
36: true,
64: true,
69: true,
83: true,
@ -272,7 +273,7 @@ func unpackMessage[T soulseekMessage](reader io.Reader) (T, error) {
return data, nil
}
func readMessage(reader io.Reader) (soulseekMessage, error) {
func (b* Bsoulseek) readMessage(reader io.Reader) (soulseekMessage, error) {
var length uint32
err := binary.Read(reader, binary.LittleEndian, &length)
if err != nil {
@ -321,10 +322,10 @@ func readMessage(reader io.Reader) (soulseekMessage, error) {
return unpackMessage[privateMessageReceive](reader)
default:
_, ignore := ignoreMessageCodes[code]
if ignore {
return nil, nil
if !ignore {
b.Log.Errorf("Unknown message code: %d", code)
}
return nil, fmt.Errorf("Unknown message code: %d", code)
return nil, nil
}
}

View File

@ -37,7 +37,7 @@ func New(cfg *bridge.Config) bridge.Bridger {
func (b *Bsoulseek) receiveMessages() {
for {
msg, err := readMessage(b.conn)
msg, err := b.readMessage(b.conn)
if err != nil {
b.fatalErrors <- fmt.Errorf("Reading message failed: %s", err)
return