encode method
dynamic
encode(
- dynamic obj,
- dynamic callback
Encode a packet as a single string if non-binary, or as a buffer sequence, depending on packet type.
@param {Object} obj - packet object @param {Function} callback - function to handle encodings (likely engine.write) @return Calls callback with Array of encodings @api public
Implementation
encode(obj, callback) {
_logger.fine('encoding packet $obj');
if (BINARY_EVENT == obj['type'] || BINARY_ACK == obj['type']) {
encodeAsBinary(obj, callback);
} else {
var encoding = encodeAsString(obj);
callback([encoding]);
}
}