(...args)
| 527 | const isWildcard = hasWildcardPattern(eventType); |
| 528 | const eventPattern = isWildcard ? compileEventPattern(eventType) : null; |
| 529 | const handler = (...args) => { |
| 530 | const entry = this.subscriptions.get(eventType); |
| 531 | if (!entry) return; |
| 532 | const currentIsWildcard = Boolean(entry.eventPattern); |
| 533 | const payload = isWildcard ? args[1] : args[0]; |
| 534 | const incomingEventType = isWildcard ? args[0] : eventType; |
| 535 | if (currentIsWildcard) { |
| 536 | if (typeof incomingEventType !== "string") return; |
| 537 | if (!entry.eventPattern.test(incomingEventType)) return; |
| 538 | } |
| 539 | let envelope; |
| 540 | try { |
| 541 | envelope = validateServerEnvelope(payload); |
| 542 | } catch (error) { |
| 543 | console.error("WebSocket envelope validation failed:", error); |
| 544 | this.invokeErrorCallbacks(error); |
| 545 | return; |
| 546 | } |
| 547 | |
| 548 | entry.callbacks.forEach((cb) => { |
| 549 | try { |
| 550 | if (currentIsWildcard) { |
| 551 | cb(incomingEventType, envelope); |
| 552 | return; |
| 553 | } |
| 554 | cb(envelope); |
| 555 | } catch (error) { |
| 556 | console.error("WebSocket callback error:", error); |
| 557 | } |
| 558 | }); |
| 559 | }; |
| 560 | |
| 561 | this.subscriptions.set(eventType, { |
| 562 | eventPattern, |
no test coverage detected