socket method
Creates a socket for the given nsp
.
@return {Socket} @api public
Implementation
Socket socket(String nsp, Map opts) {
var socket = nsps[nsp];
var onConnecting = ([_]) {
if (!connecting.contains(socket)) {
connecting.add(socket);
}
};
if (socket == null) {
socket = Socket(this, nsp, opts);
nsps[nsp] = socket;
socket.on('connecting', onConnecting);
socket.on('connect', (_) {
socket!.id = generateId(nsp);
});
if (autoConnect) {
// manually call here since connecting event is fired before listening
onConnecting();
}
}
return socket;
}