Skip to content

Commit

Permalink
Merge pull request #46 from visionmedia/remove/greetings
Browse files Browse the repository at this point in the history
remove greetings
  • Loading branch information
tj committed Oct 12, 2012
2 parents d7b4aaa + 4ce89a6 commit 9284897
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/sockets/rep.js
Expand Up @@ -46,7 +46,7 @@ RepSocket.prototype.onmessage = function(sock){
msg.push(reply);
self.emit.apply(self, msg);

function reply(){
function reply() {
var args = [].slice.call(arguments);
args[0] = args[0] || null;
args.push(id);
Expand Down
26 changes: 5 additions & 21 deletions lib/sockets/sock.js
Expand Up @@ -37,7 +37,6 @@ function Socket() {
this.opts = {};
this.server = null;
this.socks = [];
this.map = {};
this.settings = {};
this.format('none');
this.set('identity', String(process.pid));
Expand Down Expand Up @@ -143,11 +142,10 @@ Socket.prototype.close = function(){
*/

Socket.prototype.address = function(){
if (this.server) {
var addr = this.server.address();
addr.string = 'tcp://' + addr.address + ':' + addr.port;
return addr;
}
if (!this.server) return;
var addr = this.server.address();
addr.string = 'tcp://' + addr.address + ':' + addr.port;
return addr;
};

/**
Expand Down Expand Up @@ -176,22 +174,8 @@ Socket.prototype.addSocket = function(sock){
, parser = new Parser
, n = this.socks.push(sock);

// send our greeting
sock.write(this.pack(this.get('identity')));

// parse incoming
sock.on('data', parser.write.bind(parser));

// accept greeting once, emit messages there on out
parser.onmessage = ongreeting;

function ongreeting(msg){
var id = String(msg);
if ('0' === id) id = pid + Date.now() + n;
sock._axon_id = id;
self.map[id] = sock;
parser.onmessage = self.onmessage(sock);
}
parser.onmessage = self.onmessage(sock);
};

/**
Expand Down

0 comments on commit 9284897

Please sign in to comment.