MCPcopy
hub / github.com/socketio/socket.io / setup

Method setup

packages/socket.io/lib/client.ts:89–109  ·  view source on GitHub ↗

* Sets up event listeners. * * @private

()

Source from the content-addressed store, hash-verified

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.

Callers 1

constructorMethod · 0.95

Calls 4

closeMethod · 0.95
debugFunction · 0.85
bindMethod · 0.80
onMethod · 0.45

Tested by

no test coverage detected