* Sets up event listeners. * * @private
()
| 87 | * @private |
| 88 | */ |
| 89 | private setup() { |
| 90 | this.onclose = this.onclose.bind(this); |
| 91 | this.ondata = this.ondata.bind(this); |
| 92 | this.onerror = this.onerror.bind(this); |
| 93 | this.ondecoded = this.ondecoded.bind(this); |
| 94 | |
| 95 | // @ts-ignore |
| 96 | this.decoder.on("decoded", this.ondecoded); |
| 97 | this.conn.on("data", this.ondata); |
| 98 | this.conn.on("error", this.onerror); |
| 99 | this.conn.on("close", this.onclose); |
| 100 | |
| 101 | this.connectTimeout = setTimeout(() => { |
| 102 | if (this.nsps.size === 0) { |
| 103 | debug("no namespace joined yet, close the client"); |
| 104 | this.close(); |
| 105 | } else { |
| 106 | debug("the client has already joined a namespace, nothing to do"); |
| 107 | } |
| 108 | }, this.server._connectTimeout); |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Connects a client to a namespace. |
no test coverage detected