mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-26 04:32:03 -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{
|
var ignoreMessageCodes = map[uint32]bool{
|
||||||
7: true,
|
7: true,
|
||||||
|
36: true,
|
||||||
64: true,
|
64: true,
|
||||||
69: true,
|
69: true,
|
||||||
83: true,
|
83: true,
|
||||||
@ -272,7 +273,7 @@ func unpackMessage[T soulseekMessage](reader io.Reader) (T, error) {
|
|||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func readMessage(reader io.Reader) (soulseekMessage, error) {
|
func (b* Bsoulseek) readMessage(reader io.Reader) (soulseekMessage, error) {
|
||||||
var length uint32
|
var length uint32
|
||||||
err := binary.Read(reader, binary.LittleEndian, &length)
|
err := binary.Read(reader, binary.LittleEndian, &length)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -321,10 +322,10 @@ func readMessage(reader io.Reader) (soulseekMessage, error) {
|
|||||||
return unpackMessage[privateMessageReceive](reader)
|
return unpackMessage[privateMessageReceive](reader)
|
||||||
default:
|
default:
|
||||||
_, ignore := ignoreMessageCodes[code]
|
_, ignore := ignoreMessageCodes[code]
|
||||||
if ignore {
|
if !ignore {
|
||||||
return nil, nil
|
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() {
|
func (b *Bsoulseek) receiveMessages() {
|
||||||
for {
|
for {
|
||||||
msg, err := readMessage(b.conn)
|
msg, err := b.readMessage(b.conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.fatalErrors <- fmt.Errorf("Reading message failed: %s", err)
|
b.fatalErrors <- fmt.Errorf("Reading message failed: %s", err)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user