-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not override the destroy
method, use _destroy
instead
#135
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,18 +12,13 @@ function buildProxy (options, socketWrite, socketEnd) { | |
objectMode: options.objectMode | ||
}) | ||
|
||
proxy._destroyed = false | ||
proxy._write = socketWrite | ||
proxy._flush = socketEnd | ||
|
||
proxy.destroy = function(err) { | ||
if (this._destroyed) return | ||
this._destroyed = true | ||
|
||
proxy._destroy = function(err, cb) { | ||
var self = this | ||
process.nextTick(function() { | ||
if (err) | ||
self.emit('error', err) | ||
cb(err); | ||
self.emit('close') | ||
}) | ||
} | ||
|
@@ -155,7 +150,7 @@ function WebSocketStream(target, protocols, options) { | |
|
||
function onmessage(event) { | ||
var data = event.data | ||
if (data instanceof ArrayBuffer) data = Buffer.from(new Uint8Array(data)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is unrelated and not needed but there is no need to instantiate a new I can revert this change or move it to its own commit/PR if wanted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need. |
||
if (data instanceof ArrayBuffer) data = Buffer.from(data) | ||
else data = Buffer.from(data, 'utf8') | ||
proxy.push(data) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the default implementation with
is probably better but I didn't change it as there might be something I'm missing here.