return binary buffer

This commit is contained in:
Mark Vayngrib 2015-05-16 13:06:21 -04:00
parent 5e4a82414a
commit fa2453b4b4
1 changed files with 4 additions and 4 deletions

View File

@ -43,11 +43,10 @@ function UdpSocket(type) {
UdpSocket.prototype._debug = function() { UdpSocket.prototype._debug = function() {
// for now // for now
var args = [].slice.call(arguments) var args = [].slice.call(arguments)
args.unshift(this._id) args.unshift('socket-' + this._id)
console.log.apply(console, args) console.log.apply(null, args)
} }
UdpSocket.prototype.bind = function(port, address, callback) { UdpSocket.prototype.bind = function(port, address, callback) {
var self = this var self = this
@ -97,6 +96,7 @@ UdpSocket.prototype.close = function() {
UdpSocket.prototype._onReceive = function(info) { UdpSocket.prototype._onReceive = function(info) {
this._debug('received', info) this._debug('received', info)
// from base64 string
var buf = base64.toByteArray(info.data) var buf = base64.toByteArray(info.data)
var rinfo = { var rinfo = {
address: info.address, address: info.address,
@ -105,7 +105,7 @@ UdpSocket.prototype._onReceive = function(info) {
size: buf.length size: buf.length
} }
if (typeof Buffer !== 'undefined') buf = new Buffer(buf) if (typeof Buffer !== 'undefined') buf = new Buffer(buf, 'binary')
this.emit('message', buf, rinfo) this.emit('message', buf, rinfo)
} }