wip
This commit is contained in:
parent
5177a71a40
commit
c48c203f43
2 changed files with 30 additions and 11 deletions
|
@ -222,8 +222,10 @@ function connect(){
|
||||||
|
|
||||||
if (message.type === '__identify') {
|
if (message.type === '__identify') {
|
||||||
client.emit('__identify', {
|
client.emit('__identify', {
|
||||||
id: client.config.id
|
id: client.config.id,
|
||||||
//path: client.path
|
|
||||||
|
// TODO: This can't be right....
|
||||||
|
path: client.config.socketRoot + client.config.appspace + client.config.id
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,7 +247,22 @@ function serverCreated(socket) {
|
||||||
socket
|
socket
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.on('__identify', function(clientDetails) {
|
|
||||||
|
// Wait for handshake
|
||||||
|
var t = setTimeout(() => this.publish('error', 'Child connection did not finish handshake in time'), 2000);
|
||||||
|
|
||||||
|
// Handhake callback function
|
||||||
|
// Checks if its the same socket instance
|
||||||
|
var __identifyCb = (clientDetails, _socket) => {
|
||||||
|
if (_socket !== socket)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Clear handhake timeout
|
||||||
|
clearTimeout(t);
|
||||||
|
|
||||||
|
// Make sure event is removed
|
||||||
|
this.off('__identify', __identifyCb);
|
||||||
|
|
||||||
let id = clientDetails.id,
|
let id = clientDetails.id,
|
||||||
path = clientDetails.path,
|
path = clientDetails.path,
|
||||||
clientConfig = Object.assign(this.config, {id: id, path: path});
|
clientConfig = Object.assign(this.config, {id: id, path: path});
|
||||||
|
@ -261,7 +276,9 @@ function serverCreated(socket) {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.publish('connect', socket, this.of[id]);
|
this.publish('connect', socket, this.of[id]);
|
||||||
}.bind(this));
|
};
|
||||||
|
|
||||||
|
this.on('__identify', __identifyCb);
|
||||||
|
|
||||||
this.emit(socket, '__identify');
|
this.emit(socket, '__identify');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue