You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
feat: consolidate pubsub emitters
This commit is contained in:
@@ -58,9 +58,6 @@ function subscribeUnsubscribe (client, reply, type) {
|
||||
|
||||
function returnPubSub (client, reply) {
|
||||
const type = reply[0].toString()
|
||||
// TODO: Consolidate `message` and `pmessage`.
|
||||
// It would be more straight forward to only listen to a single "message"
|
||||
// and in case of a "pmessage" a third argument would be passed (the pattern).
|
||||
if (type === 'message') { // Channel, message
|
||||
if (typeof reply[1] !== 'string') {
|
||||
client.emit('message', reply[1].toString(), reply[2].toString())
|
||||
@@ -68,12 +65,12 @@ function returnPubSub (client, reply) {
|
||||
} else {
|
||||
client.emit('message', reply[1], reply[2])
|
||||
}
|
||||
} else if (type === 'pmessage') { // Pattern, channel, message
|
||||
} else if (type === 'pmessage') { // Channel, message, pattern
|
||||
if (typeof reply[1] !== 'string') {
|
||||
client.emit('pmessage', reply[1].toString(), reply[2].toString(), reply[3].toString())
|
||||
client.emit('pmessageBuffer', reply[1], reply[2], reply[3])
|
||||
client.emit('message', reply[2].toString(), reply[3].toString(), reply[1].toString())
|
||||
client.emit('messageBuffer', reply[2], reply[3], reply[1])
|
||||
} else {
|
||||
client.emit('pmessage', reply[1], reply[2], reply[3])
|
||||
client.emit('message', reply[2], reply[3], reply[1])
|
||||
}
|
||||
} else {
|
||||
subscribeUnsubscribe(client, reply, type)
|
||||
|
Reference in New Issue
Block a user