MCPcopy Index your code
hub / github.com/socketio/socket.io / _loop

Function _loop

client-dist/socket.io.js:1604–1628  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1602 // encodePacket efficient as it uses WS framing
1603 // no need for encodePayload
1604 var _loop = function _loop() {
1605 var packet = packets[i];
1606 var lastPacket = i === packets.length - 1;
1607 encodePacket(packet, _this3.supportsBinary, function (data) {
1608 // always create a new object (GH-437)
1609 var opts = {};
1610 // Sometimes the websocket has already been closed but the browser didn't
1611 // have a chance of informing us about it yet, in that case send will
1612 // throw an error
1613 try {
1614 if (usingBrowserWebSocket) {
1615 // TypeError is thrown when passing the second argument on Safari
1616 _this3.ws.send(data);
1617 }
1618 } catch (e) {}
1619 if (lastPacket) {
1620 // fake drain
1621 // defer to next tick to allow Socket to clear writeBuffer
1622 nextTick(function () {
1623 _this3.writable = true;
1624 _this3.emitReserved("drain");
1625 }, _this3.setTimeoutFn);
1626 }
1627 });
1628 };
1629 for (var i = 0; i < packets.length; i++) {
1630 _loop();
1631 }

Callers 1

socket.io.jsFile · 0.85

Calls 3

encodePacketFunction · 0.85
sendMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected