Fix: Move WS error handling (#174)

Moves all WS handling of unexpected payloads into the stream to prevent code duplication.

This also prevents non-{Hello,Resumed,Ready} messages from causing a handshake failure, as it seems Discord do not prevent such messages from appearing.

---------

Co-authored-by: Kyle Simpson <kyleandrew.simpson@gmail.com>
This commit is contained in:
Erk
2023-04-11 13:01:07 +02:00
committed by Kyle Simpson
parent 4d0c1c030d
commit 500d679ae5
6 changed files with 9 additions and 27 deletions

View File

@@ -95,8 +95,6 @@ impl Connection {
},
other => {
debug!("Expected ready/hello; got: {:?}", other);
return Err(Error::ExpectedHandshake);
},
}
}
@@ -304,8 +302,6 @@ impl Connection {
},
other => {
debug!("Expected resumed/hello; got: {:?}", other);
return Err(Error::ExpectedHandshake);
},
}
}