onClose method

dynamic onClose([
  1. dynamic reason
])

Called upon closing. Called by Client.

@param {String} reason @param {Error} optional error object @api private

Implementation

dynamic onClose([reason]) {
  if (!connected) return this;
  emit('disconnecting', reason);
  leaveAll();
  nsp.remove(this);
  client.remove(this);
  connected = false;
  disconnected = true;
  nsp.connected.remove(id);
  emit('disconnect', reason);
}