(options, connectionListener)
| 1988 | } |
| 1989 | |
| 1990 | function Server(options, connectionListener) { |
| 1991 | if (!(this instanceof Server)) |
| 1992 | return new Server(options, connectionListener); |
| 1993 | |
| 1994 | EventEmitter.call(this); |
| 1995 | |
| 1996 | if (typeof options === 'function') { |
| 1997 | connectionListener = options; |
| 1998 | options = kEmptyObject; |
| 1999 | this.on('connection', connectionListener); |
| 2000 | } else if (options == null || typeof options === 'object') { |
| 2001 | options = { ...options }; |
| 2002 | |
| 2003 | if (typeof connectionListener === 'function') { |
| 2004 | this.on('connection', connectionListener); |
| 2005 | } |
| 2006 | } else { |
| 2007 | throw new ERR_INVALID_ARG_TYPE('options', 'Object', options); |
| 2008 | } |
| 2009 | if (options.keepAliveInitialDelay !== undefined) { |
| 2010 | validateNumber( |
| 2011 | options.keepAliveInitialDelay, 'options.keepAliveInitialDelay', |
| 2012 | ); |
| 2013 | |
| 2014 | if (options.keepAliveInitialDelay < 0) { |
| 2015 | options.keepAliveInitialDelay = 0; |
| 2016 | } |
| 2017 | } |
| 2018 | if (options.highWaterMark !== undefined) { |
| 2019 | validateNumber( |
| 2020 | options.highWaterMark, 'options.highWaterMark', |
| 2021 | ); |
| 2022 | |
| 2023 | if (options.highWaterMark < 0) { |
| 2024 | options.highWaterMark = getDefaultHighWaterMark(); |
| 2025 | } |
| 2026 | } |
| 2027 | |
| 2028 | this._connections = 0; |
| 2029 | |
| 2030 | this[async_id_symbol] = -1; |
| 2031 | this._handle = null; |
| 2032 | this._usingWorkers = false; |
| 2033 | this._workers = []; |
| 2034 | this._unref = false; |
| 2035 | this._listeningId = 1; |
| 2036 | |
| 2037 | this.allowHalfOpen = options.allowHalfOpen || false; |
| 2038 | this.pauseOnConnect = !!options.pauseOnConnect; |
| 2039 | this.noDelay = Boolean(options.noDelay); |
| 2040 | this.keepAlive = Boolean(options.keepAlive); |
| 2041 | this.keepAliveInitialDelay = ~~(options.keepAliveInitialDelay / 1000); |
| 2042 | this.highWaterMark = options.highWaterMark ?? getDefaultHighWaterMark(); |
| 2043 | if (options.blockList) { |
| 2044 | if (!module.exports.BlockList.isBlockList(options.blockList)) { |
| 2045 | throw new ERR_INVALID_ARG_TYPE('options.blockList', 'net.BlockList', options.blockList); |
| 2046 | } |
| 2047 | this.blockList = options.blockList; |
nothing calls this directly
no test coverage detected
searching dependent graphs…