connect method
Connects a client to a namespace.
name
namespace name
Implementation
void connect(String name, [query]) {
if (!server.nsps.containsKey(name)) {
packet(<dynamic, dynamic>{
'type': errorValue,
'nsp': name,
'data': 'Invalid namespace'
});
return;
}
var nsp = server.of(name);
if ('/' != name && !nsps.containsKey('/')) {
connectBuffer.add(name);
return;
}
var self = this;
nsp.add(this, query, (socket) {
self.sockets.add(socket);
self.nsps[nsp.name] = socket;
if ('/' == nsp.name && self.connectBuffer.isNotEmpty) {
self.connectBuffer.forEach(self.connect);
self.connectBuffer = [];
}
});
}