diff --git a/index.js b/index.js index 9725aad..ac2db1c 100644 --- a/index.js +++ b/index.js @@ -51,7 +51,7 @@ class Channel { } async open(handshake) { - if (this._slave) { + if (this._mux._slave) { await this._mux.pullLocal(); await this._mux.pullFree(); } @@ -65,7 +65,7 @@ class Channel { this._localId = id + 1; this._mux._local[id] = this; - if (this._slave) { + if (this._mux._slave) { if (freeLen > 0) { await this._mux.popFree(id); } else { @@ -153,14 +153,14 @@ class Channel { if (this._remoteId > 0) { this._mux._remote[this._remoteId - 1] = null; this._remoteId = 0; - if (this._slave) { + if (this._mux._slave) { await this._mux.pullFree(); } // If remote has acked, we can reuse the local id now // otherwise, we need to wait for the "ack" to arrive this._mux._free.push(this._localId - 1); - if (this._slave) { + if (this._mux._slave) { await this._mux.pushFree(this._localId - 1); } }