encodeBuffer static method
dynamic
encodeBuffer(
- dynamic packet,
- dynamic supportsBinary,
- dynamic callback, {
- dynamic fromClient = false,
Encode Buffer data
Implementation
static encodeBuffer(packet, supportsBinary, callback,
{fromClient = false /*use this to check whether is in client or not*/}) {
if (!supportsBinary) {
return encodeBase64Packet(packet, callback);
}
var data = packet['data'];
// 'fromClient' is to check if the runtime is on server side or not,
// because Dart server's websocket cannot send data with byte buffer.
if (fromClient) {
return callback(data.buffer);
} else {
return callback(data);
}
}