(options)
| 17 | const ServerProtocolError = scErrors.ServerProtocolError; |
| 18 | |
| 19 | function AGServer(options) { |
| 20 | AsyncStreamEmitter.call(this); |
| 21 | |
| 22 | let opts = { |
| 23 | brokerEngine: new AGSimpleBroker(), |
| 24 | wsEngine: 'ws', |
| 25 | wsEngineServerOptions: {}, |
| 26 | maxPayload: null, |
| 27 | allowClientPublish: true, |
| 28 | ackTimeout: 10000, |
| 29 | handshakeTimeout: 10000, |
| 30 | strictHandshake: true, |
| 31 | pingTimeout: 20000, |
| 32 | pingTimeoutDisabled: false, |
| 33 | pingInterval: 8000, |
| 34 | origins: '*:*', |
| 35 | path: '/socketcluster/', |
| 36 | protocolVersion: 2, |
| 37 | authDefaultExpiry: 86400, |
| 38 | batchOnHandshake: false, |
| 39 | batchOnHandshakeDuration: 400, |
| 40 | batchInterval: 50, |
| 41 | middlewareEmitFailures: true, |
| 42 | socketStreamCleanupMode: 'kill', |
| 43 | cloneData: false |
| 44 | }; |
| 45 | |
| 46 | this.options = Object.assign(opts, options); |
| 47 | |
| 48 | this._middleware = {}; |
| 49 | |
| 50 | this.origins = opts.origins; |
| 51 | this._allowAllOrigins = this.origins.indexOf('*:*') !== -1; |
| 52 | |
| 53 | this.ackTimeout = opts.ackTimeout; |
| 54 | this.handshakeTimeout = opts.handshakeTimeout; |
| 55 | this.pingInterval = opts.pingInterval; |
| 56 | this.pingTimeout = opts.pingTimeout; |
| 57 | this.pingTimeoutDisabled = opts.pingTimeoutDisabled; |
| 58 | this.allowClientPublish = opts.allowClientPublish; |
| 59 | this.perMessageDeflate = opts.perMessageDeflate; |
| 60 | this.httpServer = opts.httpServer; |
| 61 | this.socketChannelLimit = opts.socketChannelLimit; |
| 62 | this.protocolVersion = opts.protocolVersion; |
| 63 | this.strictHandshake = opts.strictHandshake; |
| 64 | |
| 65 | this.brokerEngine = opts.brokerEngine; |
| 66 | this.middlewareEmitFailures = opts.middlewareEmitFailures; |
| 67 | |
| 68 | this._path = opts.path; |
| 69 | |
| 70 | (async () => { |
| 71 | for await (let {error} of this.brokerEngine.listener('error')) { |
| 72 | this.emitWarning(error); |
| 73 | } |
| 74 | })(); |
| 75 | |
| 76 | if (this.brokerEngine.isReady) { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…