Work with subarrays

post-data
Clément FRÉVILLE 2 years ago
parent 5f5bc146d4
commit c04e02190a

@ -52,13 +52,13 @@ server.listen(port, () => {
}); });
for await (const [buff] of receiver) { for await (const [buff] of receiver) {
const jobId = buff.slice(0, 32).toString(); const jobId = buff.subarray(0, 32).toString();
console.log(`Received ${jobId}`); console.log(`Received ${jobId}`);
const res = clients[jobId]; const res = clients[jobId];
if (!res) { if (!res) {
continue; continue;
} }
res.write('event: message\n'); res.write('event: message\n');
res.write(`data: ${encodeURIComponent(buff.slice(32).toString())}\n`); res.write(`data: ${encodeURIComponent(buff.subarray(32).toString())}\n`);
res.write('id: 0\n'); res.write('id: 0\n');
} }

Loading…
Cancel
Save