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

Function encodePayload

client-dist/socket.io.js:442–456  ·  view source on GitHub ↗
(packets, callback)

Source from the content-addressed store, hash-verified

440
441 var SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text
442 var encodePayload = function encodePayload(packets, callback) {
443 // some packets may be added to the array while encoding, so the initial length must be saved
444 var length = packets.length;
445 var encodedPackets = new Array(length);
446 var count = 0;
447 packets.forEach(function (packet, i) {
448 // force base64 encoding for binary packets
449 encodePacket(packet, false, function (encodedPacket) {
450 encodedPackets[i] = encodedPacket;
451 if (++count === length) {
452 callback(encodedPackets.join(SEPARATOR));
453 }
454 });
455 });
456 };
457 var decodePayload = function decodePayload(encodedPayload, binaryType) {
458 var encodedPackets = encodedPayload.split(SEPARATOR);
459 var packets = [];

Callers 1

socket.io.jsFile · 0.85

Calls 3

encodePacketFunction · 0.85
callbackFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected