Permalink
Browse files

fix disconnecting

  • Loading branch information...
1 parent f716ce8 commit e8b764a514438ec58a31b3dd4a6cc9441cea7ca1 @defunctzombie committed Nov 10, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 socket.js
View
@@ -28,10 +28,18 @@ Socket.prototype.write = function(data) {
/// write {ArrayBuffer} data and then end connection
Socket.prototype.end = function(data) {
- chrome.socket.disconnect(self.socket_id);
+ var self = this;
+
+ if (data) {
+ self.write(data);
+ }
+
+ chrome.socket.disconnect(self._socket_info.socketId);
self.emit('end');
self.emit('close');
+
+ return self;
};
/// connect to the given port and host

0 comments on commit e8b764a

Please sign in to comment.