Skip to content
Browse files

added connection check on write method

  • Loading branch information...
1 parent d3f6feb commit f862e7c32a6fd74092870e8afd6c124fb03eb19b @kilianc committed
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/nssocket.js
View
5 lib/nssocket.js
@@ -84,7 +84,12 @@ NsSocket.prototype.connect = function connect(port) {
}
NsSocket.prototype.write = function write(buff) {
+ // if we aren't connected/socketed, then error
+ if (!this.socket || !this.connected) {
+ return this.emit('error', new Error('NsSocket: sending on a bad socket'))
+ }
this.stream.write(buff)
+ return this
}
NsSocket.prototype.send = function send(event, data, callback) {

0 comments on commit f862e7c

Please sign in to comment.
Something went wrong with that request. Please try again.