lyxaira.glass 8df8a0d9ff Programa es js que permite la copia de archivos de un folder a otro, de manera local por el momento. | 5 years ago | |
---|---|---|
.. | ||
node_modules | 5 years ago | |
LICENSE | 5 years ago | |
Readme.md | 5 years ago | |
binary.js | 5 years ago | |
index.js | 5 years ago | |
is-buffer.js | 5 years ago | |
package.json | 5 years ago |
A socket.io encoder and decoder written in JavaScript complying with version 4
of socket.io-protocol.
Used by socket.io and
socket.io-client.
socket.io-parser is the reference implementation of socket.io-protocol. Read the full API here: socket.io-protocol.
var parser = require('socket.io-parser');
var encoder = new parser.Encoder();
var packet = {
type: parser.EVENT,
data: 'test-packet',
id: 13
};
encoder.encode(packet, function(encodedPackets) {
var decoder = new parser.Decoder();
decoder.on('decoded', function(decodedPacket) {
// decodedPacket.type == parser.EVENT
// decodedPacket.data == 'test-packet'
// decodedPacket.id == 13
});
for (var i = 0; i < encodedPackets.length; i++) {
decoder.add(encodedPackets[i]);
}
});
var parser = require('socket.io-parser');
var encoder = new parser.Encoder();
var packet = {
type: parser.BINARY_EVENT,
data: {i: new Buffer(1234), j: new Blob([new ArrayBuffer(2)])}
id: 15
};
encoder.encode(packet, function(encodedPackets) {
var decoder = new parser.Decoder();
decoder.on('decoded', function(decodedPacket) {
// decodedPacket.type == parser.BINARY_EVENT
// Buffer.isBuffer(decodedPacket.data.i) == true
// Buffer.isBuffer(decodedPacket.data.j) == true
// decodedPacket.id == 15
});
for (var i = 0; i < encodedPackets.length; i++) {
decoder.add(encodedPackets[i]);
}
});
See the test suite for more examples of how socket.io-parser is used.
MIT