1,584
edits
(fixed constant name to correspond with the source code) Tag: Source edit |
DrinkyBird (talk | contribs) (update example) Tag: Source edit |
||
Line 626: | Line 626: | ||
=== Example code === | === Example code === | ||
Validation of the given offsets and sizes has been omitted here. | |||
<syntaxhighlight lang="javascript" line="1"> | <syntaxhighlight lang="javascript" line="1"> | ||
let receivedSegments = 0; | |||
function handlePacket(data) { | function handlePacket(data) { | ||
const response = data.readLong(); | const response = data.readLong(); | ||
Line 649: | Line 652: | ||
copyBuffer(from: data, to: buffer, toOffset: offset); | copyBuffer(from: data, to: buffer, toOffset: offset); | ||
receivedSegments++; | |||
if ( | if (receivedSegments == totalSegments) { | ||
parseResponse(buffer); | parseResponse(buffer); | ||
} | } |