Add binary frames support and tests, to close feature request #38.
This commit is contained in:
@@ -31,6 +31,23 @@ wssEchoWithSize.on('connection', function(ws) {
|
||||
});
|
||||
});
|
||||
|
||||
var wssBinaryEchoWithSize = new WebSocketServer({server: app, path: '/binaryEchoWithSize'});
|
||||
wssBinaryEchoWithSize.on('connection', function(ws) {
|
||||
ws.on('message', function(data, flags) {
|
||||
if (!flags.binary) { return; }
|
||||
//var result = new ArrayBuffer(data.length + 4);
|
||||
//new DataView(result).setInt32(0, data.length, false); // false = big endian
|
||||
var result = new Buffer(data.length + 4);
|
||||
result.writeInt32BE(data.length, 0);
|
||||
data.copy(result, 4, 0, data.length);
|
||||
ws.send(result, { binary: true });
|
||||
});
|
||||
ws.on('close', function() {
|
||||
});
|
||||
ws.on('error', function(e) {
|
||||
});
|
||||
});
|
||||
|
||||
var wssKillServer = new WebSocketServer({server: app, path: '/killServer'});
|
||||
wssKillServer.on('connection', function(ws) {
|
||||
ws.on('message', function(data, flags) {
|
||||
|
||||
Reference in New Issue
Block a user