* For polling, send a close packet. * * @protected
()
| 120 | * @protected |
| 121 | */ |
| 122 | override doClose() { |
| 123 | const close = () => { |
| 124 | debug("writing close packet"); |
| 125 | this.write([{ type: "close" }]); |
| 126 | }; |
| 127 | |
| 128 | if ("open" === this.readyState) { |
| 129 | debug("transport open - closing"); |
| 130 | close(); |
| 131 | } else { |
| 132 | // in case we're trying to close while |
| 133 | // handshaking is in progress (GH-164) |
| 134 | debug("transport not open - deferring close"); |
| 135 | this.once("open", close); |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Writes a packets payload. |