(port)
| 67 | } |
| 68 | |
| 69 | initPort(port) { |
| 70 | this._port = port; |
| 71 | this._port.onMessage.addListener(this.handlePortMessage.bind(this)); |
| 72 | this.#portName = port.name; |
| 73 | if (this._port.onDisconnect) { |
| 74 | this._port.onDisconnect.addListener(() => this.handleDisconnect()); |
| 75 | for (const listener of this.#disconnectListener) { |
| 76 | this._port.onDisconnect.addListener(listener); |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | handleDisconnect() { |
| 82 | this.clearPort(); |
no test coverage detected