Skip to content

Commit

Permalink
Simplify fragmented_message_opcode logic
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Reidel <adrian@travitia.xyz>
  • Loading branch information
Gelbpunkt committed Sep 5, 2024
1 parent 36ab31f commit 249668c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/proto/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,9 @@ impl Decoder for WebSocketProtocol {
// It is possible to receive intermediate control frames between a large other
// frame. We therefore can't simply reset the fragmented opcode after we receive
// a "final" frame.
if fin && !opcode.is_control() {
// Full, (possibly) chunked message received
self.fragmented_message_opcode = OpCode::Continuation;
} else if opcode != OpCode::Continuation && !opcode.is_control() {
// First frame of a multi-frame message
if (fin && opcode == OpCode::Continuation) || (!fin && opcode != OpCode::Continuation) {
// Full chunked message received (and opcode is Continuation)
// or first frame of a multi-frame message received
self.fragmented_message_opcode = opcode;
}
// In all other cases, we have either a continuation or control frame, neither
Expand Down

0 comments on commit 249668c

Please sign in to comment.