Skip to content

Commit

Permalink
fix(buffer) return buffer data
Browse files Browse the repository at this point in the history
  • Loading branch information
subnetmarco committed Jan 15, 2019
1 parent 5072a51 commit d18c66f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (cluster.isMaster) {
socket.on('data', function(data) {
var response = {
"client-ip": socket.remoteAddress,
"data": data,
"data": data.toJSON().data,
"text-data": data.toString(),
"size": data.length
}
Expand All @@ -46,7 +46,7 @@ if (cluster.isMaster) {
udp_info_server.on("message", function(msg, rinfo) {
var response = JSON.stringify({
"client-ip": rinfo.address,
"data": msg,
"data": msg.toJSON().data,
"text-data": msg.toString(),
"size": msg.length
});
Expand Down
4 changes: 2 additions & 2 deletions tests/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Tcpbin', function () {
client.write('TCP info test');
});
client.on('data', function(data) {
should(data.toString()).equal('{"client-ip":"::ffff:127.0.0.1","data":{"type":"Buffer","data":[84,67,80,32,105,110,102,111,32,116,101,115,116]},"text-data":"TCP info test","size":13}');
should(data.toString()).equal('{"client-ip":"::ffff:127.0.0.1","data":[84,67,80,32,105,110,102,111,32,116,101,115,116],"text-data":"TCP info test","size":13}');
done();
});
});
Expand All @@ -47,7 +47,7 @@ describe('Tcpbin', function () {
it('should get info', function (done) {
var client = dgram.createSocket('udp4');
client.on('message', function(message, remote) {
should(message.toString()).equal('{"client-ip":"127.0.0.1","data":{"type":"Buffer","data":[85,68,80,32,105,110,102,111,32,116,101,115,116]},"text-data":"UDP info test","size":13}');
should(message.toString()).equal('{"client-ip":"127.0.0.1","data":[85,68,80,32,105,110,102,111,32,116,101,115,116],"text-data":"UDP info test","size":13}');
done();
});
var message = new Buffer.from('UDP info test');
Expand Down

0 comments on commit d18c66f

Please sign in to comment.