MCPcopy
hub / github.com/socketio/socket.io / waitForPackets

Function waitForPackets

docs/socket.io-protocol/v5-test-suite/test-suite.js:51–68  ·  view source on GitHub ↗
(socket, count)

Source from the content-addressed store, hash-verified

49}
50
51function waitForPackets(socket, count) {
52 const packets = [];
53
54 return new Promise((resolve) => {
55 const handler = (event) => {
56 if (event.data === "2") {
57 // ignore PING packets
58 return;
59 }
60 packets.push(event.data);
61 if (packets.length === count) {
62 socket.removeEventListener("message", handler);
63 resolve(packets);
64 }
65 };
66 socket.addEventListener("message", handler);
67 });
68}
69
70async function initLongPollingSession() {
71 const response = await fetch(`${URL}/socket.io/?EIO=4&transport=polling`);

Callers 1

test-suite.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected