Skip to content

Commit

Permalink
Fixed issue that caused long running p2p livestreams to be interrupted
Browse files Browse the repository at this point in the history
  • Loading branch information
bropat committed Dec 17, 2023
1 parent 4d85da8 commit 03a48bb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/p2p/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,16 @@ export const buildCommandWithStringTypePayload = (encryptionType: EncryptionType
export const sortP2PMessageParts = (messages: P2PMessageParts): Buffer => {
let completeMessage = Buffer.from([]);
Object.keys(messages).map(Number)
.sort((a, b) => a - b) // assure the seqNumbers are in correct order
.sort((a, b) => {
if (Math.abs(a - b) > 65000) {
if (a < b) {
return 1;
} else if (b < a) {
return -1;
}
}
return a - b;
}) // assure the seqNumbers are in correct order
.forEach((key: number) => {
completeMessage = Buffer.concat([completeMessage, messages[key]]);
});
Expand Down

0 comments on commit 03a48bb

Please sign in to comment.