Skip to content

Commit

Permalink
Emit 'end' and 'close' events only when main connection closes
Browse files Browse the repository at this point in the history
  • Loading branch information
unkernet authored and mscdex committed Nov 29, 2011
1 parent 2af0833 commit aac8d5a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions oscar.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -788,10 +788,11 @@ function end_handler(oscar) {
var self = oscar, conn = this; var self = oscar, conn = this;
conn.isConnected = false; conn.isConnected = false;
if (!conn.isTransferring) { if (!conn.isTransferring) {
if (conn === self._state.connections.main) if (conn === self._state.connections.main) {
self._resetState(); self._resetState();
self.emit('end');
}
debug('(' + conn.remoteAddress + ') [' + getConnSvcNames(conn) + '] FIN packet received. Disconnecting...'); debug('(' + conn.remoteAddress + ') [' + getConnSvcNames(conn) + '] FIN packet received. Disconnecting...');
self.emit('end');
} }
} }


Expand All @@ -810,10 +811,11 @@ function close_handler(oscar, had_error) {
var self = oscar, conn = this; var self = oscar, conn = this;
conn.isConnected = false; conn.isConnected = false;
if (!conn.isTransferring || had_error) { if (!conn.isTransferring || had_error) {
if (conn === self._state.connections.main) if (conn === self._state.connections.main) {
self._resetState(); self._resetState();
self.emit('close', had_error);
}
debug('(' + conn.remoteAddress + ') [' + getConnSvcNames(conn) + '] Connection forcefully closed.'); debug('(' + conn.remoteAddress + ') [' + getConnSvcNames(conn) + '] Connection forcefully closed.');
self.emit('close', had_error);
} }
} }


Expand Down

0 comments on commit aac8d5a

Please sign in to comment.