Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob McElrath committed Mar 1, 2017
1 parent 94ebd78 commit ac93502
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -815,16 +815,20 @@ Socket.prototype._read = function (bufferSize) {
Socket.prototype._onReceive = function (data) {
var buffer = Buffer.from(data)
var offset = this.bytesRead
console.log("onReceive got "+buffer.length+" bytes: "+buffer.slice(0,50).toString('hex')+"...")

this.bytesRead += buffer.length
this._unrefTimer()
//this._unrefTimer()

if (this.ondata) {
console.error('socket.ondata = func is non-standard, use socket.on(\'data\', func)')
this.ondata(buffer, offset, this.bytesRead)
}
// FIXME when this returns false, it seems it is not actually putting data in
// the stream.
if (!this.push(buffer)) { // if returns false, then apply backpressure
chrome.sockets.tcp.setPaused(this.id, true)
console.warn("Socket.push returned false, pausing socket.")
chrome.sockets.tcp.setPaused(this.id, true) // onReceive will be called again with this data
}
}

Expand Down

0 comments on commit ac93502

Please sign in to comment.