Skip to content

Commit

Permalink
Don't "connect" until setting up all connection-related information f…
Browse files Browse the repository at this point in the history
…irst, including event handlers
  • Loading branch information
mscdex committed Jul 4, 2012
1 parent 6d15950 commit eb51a63
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion oscar.js
Expand Up @@ -846,7 +846,7 @@ OscarConnection.prototype._resetState = function() {

OscarConnection.prototype._addConnection = function(id, services, host, port, cb) {
var self = this;
self._state.connections[id] = net.createConnection(port, host);
self._state.connections[id] = new net.Socket();
self._state.connections[id].id = id;
self._state.connections[id].neededServices = services;
self._state.connections[id].serverType = (id === 'login' ? 'login' : 'BOS');
Expand All @@ -872,6 +872,7 @@ OscarConnection.prototype._addConnection = function(id, services, host, port, cb
self._state.connections[id].on('end', function() { end_handler.call(this, self); });
self._state.connections[id].on('error', function(err) { error_handler.call(this, self, err, cb); });
self._state.connections[id].on('close', function(had_error) { close_handler.call(this, self, had_error); });
self._state.connections[id].connect(port, host);
}

OscarConnection.prototype._addService = function(svc, roomInfo, cb) {
Expand Down

0 comments on commit eb51a63

Please sign in to comment.