(
type: PubSubType,
message: Buffer,
channel: Buffer,
pattern?: Buffer
)
| 448 | } |
| 449 | |
| 450 | #emitPubSubMessage( |
| 451 | type: PubSubType, |
| 452 | message: Buffer, |
| 453 | channel: Buffer, |
| 454 | pattern?: Buffer |
| 455 | ): void { |
| 456 | const keyString = (pattern ?? channel).toString(), |
| 457 | listeners = this.listeners[type].get(keyString); |
| 458 | |
| 459 | if (!listeners) return; |
| 460 | |
| 461 | publish(CHANNELS.PUBSUB, () => ({ |
| 462 | direction: 'in' as const, |
| 463 | clientId: this.#clientId, |
| 464 | channel, |
| 465 | sharded: type === PUBSUB_TYPE.SHARDED, |
| 466 | })); |
| 467 | |
| 468 | for (const listener of listeners.buffers) { |
| 469 | listener(message, channel); |
| 470 | } |
| 471 | |
| 472 | if (!listeners.strings.size) return; |
| 473 | |
| 474 | const channelString = pattern ? channel.toString() : keyString, |
| 475 | messageString = channelString === '__redis__:invalidate' ? |
| 476 | // https://github.com/redis/redis/pull/7469 |
| 477 | // https://github.com/redis/redis/issues/7463 |
| 478 | (message === null ? null : (message as any as Array<Buffer>).map(x => x.toString())) as any : |
| 479 | message.toString(); |
| 480 | for (const listener of listeners.strings) { |
| 481 | listener(messageString, channelString); |
| 482 | } |
| 483 | } |
| 484 | } |
no test coverage detected