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

Function encodePayload

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

Source from the content-addressed store, hash-verified

353
354 var SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text
355 var encodePayload = function encodePayload(packets, callback) {
356 // some packets may be added to the array while encoding, so the initial length must be saved
357 var length = packets.length;
358 var encodedPackets = new Array(length);
359 var count = 0;
360 packets.forEach(function (packet, i) {
361 // force base64 encoding for binary packets
362 encodePacket(packet, false, function (encodedPacket) {
363 encodedPackets[i] = encodedPacket;
364 if (++count === length) {
365 callback(encodedPackets.join(SEPARATOR));
366 }
367 });
368 });
369 };
370 var decodePayload = function decodePayload(encodedPayload, binaryType) {
371 var encodedPackets = encodedPayload.split(SEPARATOR);
372 var packets = [];

Callers 1

socket.io.jsFile · 0.70

Calls 3

encodePacketFunction · 0.70
callbackFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected