* @private * @returns {string} client transport
()
| 1489 | * @returns {string} client transport |
| 1490 | */ |
| 1491 | getClientTransport() { |
| 1492 | let clientImplementation; |
| 1493 | let clientImplementationFound = true; |
| 1494 | |
| 1495 | const isKnownWebSocketServerImplementation = |
| 1496 | this.options.webSocketServer && |
| 1497 | typeof ( |
| 1498 | /** @type {WebSocketServerConfiguration} */ |
| 1499 | (this.options.webSocketServer).type |
| 1500 | ) === "string" && |
| 1501 | // @ts-expect-error |
| 1502 | this.options.webSocketServer.type === "ws"; |
| 1503 | |
| 1504 | let clientTransport; |
| 1505 | |
| 1506 | if (this.options.client) { |
| 1507 | if ( |
| 1508 | typeof ( |
| 1509 | /** @type {ClientConfiguration} */ |
| 1510 | (this.options.client).webSocketTransport |
| 1511 | ) !== "undefined" |
| 1512 | ) { |
| 1513 | clientTransport = |
| 1514 | /** @type {ClientConfiguration} */ |
| 1515 | (this.options.client).webSocketTransport; |
| 1516 | } else if (isKnownWebSocketServerImplementation) { |
| 1517 | clientTransport = |
| 1518 | /** @type {WebSocketServerConfiguration} */ |
| 1519 | (this.options.webSocketServer).type; |
| 1520 | } else { |
| 1521 | clientTransport = "ws"; |
| 1522 | } |
| 1523 | } else { |
| 1524 | clientTransport = "ws"; |
| 1525 | } |
| 1526 | |
| 1527 | switch (typeof clientTransport) { |
| 1528 | case "string": |
| 1529 | // could be 'ws', or a path that should be resolved |
| 1530 | if (clientTransport === "ws") { |
| 1531 | clientImplementation = cjsRequire.resolve( |
| 1532 | "../client/clients/WebSocketClient.js", |
| 1533 | ); |
| 1534 | } else { |
| 1535 | try { |
| 1536 | clientImplementation = cjsRequire.resolve(clientTransport); |
| 1537 | } catch { |
| 1538 | clientImplementationFound = false; |
| 1539 | } |
| 1540 | } |
| 1541 | break; |
| 1542 | default: |
| 1543 | clientImplementationFound = false; |
| 1544 | } |
| 1545 | |
| 1546 | if (!clientImplementationFound) { |
| 1547 | throw new Error( |
| 1548 | `${ |