mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-22 02:32:02 -08:00
Better ignore message handling
This commit is contained in:
parent
723a426203
commit
56cad911af
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user