add method
Adds a new client.
Implementation
Socket add(Client client, query, Function? fn) {
var socket = Socket(this, client, query);
var self = this;
run(socket, (err) {
// don't use Timer.run() here
scheduleMicrotask(() {
if ('open' == client.conn.readyState) {
if (err != null) return socket.error(err.data || err.message);
self.sockets.add(socket);
socket.onconnect();
if (fn != null) fn(socket);
// fire user-set events
self.emit('connect', socket);
self.emit('connection', socket);
}
});
});
return socket;
}