Server constructor

Server({
  1. dynamic server,
  2. Map? options,
})

Server constructor.

@param {http.Server|Number|Object} http server, port or options @param {Object} options @api public

Implementation

Server({server, Map? options}) {
  options ??= {};
  path(options.containsKey('path') ? options['path'] : '/socket.io');
  serveClient(false != options['serveClient']);
  adapter = options.containsKey('adapter') ? options['adapter'] : 'default';
  origins(options.containsKey('origins') ? options['origins'] : '*:*');
  sockets = of('/');
  if (server != null) {
    _ready = Future(() async {
      await attach(server, options);
      return true;
    });
  } else {
    _ready = Future.value(true);
  }
}