Commit eaaac088 authored by antirez's avatar antirez
Browse files

RESP3: Pubsub messages in new push format if client is in RESP3 mode.

parent bc75a94e
...@@ -37,7 +37,10 @@ int clientSubscriptionsCount(client *c); ...@@ -37,7 +37,10 @@ int clientSubscriptionsCount(client *c);
/* Send a pubsub message of type "message" to the client. */ /* Send a pubsub message of type "message" to the client. */
void addReplyPubsubMessage(client *c, robj *channel, robj *msg) { void addReplyPubsubMessage(client *c, robj *channel, robj *msg) {
if (c->resp == 2)
addReply(c,shared.mbulkhdr[3]); addReply(c,shared.mbulkhdr[3]);
else
addReplyPushLen(c,3);
addReply(c,shared.messagebulk); addReply(c,shared.messagebulk);
addReplyBulk(c,channel); addReplyBulk(c,channel);
addReplyBulk(c,msg); addReplyBulk(c,msg);
...@@ -47,7 +50,10 @@ void addReplyPubsubMessage(client *c, robj *channel, robj *msg) { ...@@ -47,7 +50,10 @@ void addReplyPubsubMessage(client *c, robj *channel, robj *msg) {
* with the "message" type delivered by addReplyPubsubMessage() is that * with the "message" type delivered by addReplyPubsubMessage() is that
* this message format also includes the pattern that matched the message. */ * this message format also includes the pattern that matched the message. */
void addReplyPubsubPatMessage(client *c, robj *pat, robj *channel, robj *msg) { void addReplyPubsubPatMessage(client *c, robj *pat, robj *channel, robj *msg) {
if (c->resp == 2)
addReply(c,shared.mbulkhdr[4]); addReply(c,shared.mbulkhdr[4]);
else
addReplyPushLen(c,4);
addReply(c,shared.pmessagebulk); addReply(c,shared.pmessagebulk);
addReplyBulk(c,pat); addReplyBulk(c,pat);
addReplyBulk(c,channel); addReplyBulk(c,channel);
...@@ -56,7 +62,10 @@ void addReplyPubsubPatMessage(client *c, robj *pat, robj *channel, robj *msg) { ...@@ -56,7 +62,10 @@ void addReplyPubsubPatMessage(client *c, robj *pat, robj *channel, robj *msg) {
/* Send the pubsub subscription notification to the client. */ /* Send the pubsub subscription notification to the client. */
void addReplyPubsubSubscribed(client *c, robj *channel) { void addReplyPubsubSubscribed(client *c, robj *channel) {
if (c->resp == 2)
addReply(c,shared.mbulkhdr[3]); addReply(c,shared.mbulkhdr[3]);
else
addReplyPushLen(c,3);
addReply(c,shared.subscribebulk); addReply(c,shared.subscribebulk);
addReplyBulk(c,channel); addReplyBulk(c,channel);
addReplyLongLong(c,clientSubscriptionsCount(c)); addReplyLongLong(c,clientSubscriptionsCount(c));
...@@ -67,7 +76,10 @@ void addReplyPubsubSubscribed(client *c, robj *channel) { ...@@ -67,7 +76,10 @@ void addReplyPubsubSubscribed(client *c, robj *channel) {
* unsubscribe command but there are no channels to unsubscribe from: we * unsubscribe command but there are no channels to unsubscribe from: we
* still send a notification. */ * still send a notification. */
void addReplyPubsubUnsubscribed(client *c, robj *channel) { void addReplyPubsubUnsubscribed(client *c, robj *channel) {
if (c->resp == 2)
addReply(c,shared.mbulkhdr[3]); addReply(c,shared.mbulkhdr[3]);
else
addReplyPushLen(c,3);
addReply(c,shared.unsubscribebulk); addReply(c,shared.unsubscribebulk);
if (channel) if (channel)
addReplyBulk(c,channel); addReplyBulk(c,channel);
...@@ -78,7 +90,10 @@ void addReplyPubsubUnsubscribed(client *c, robj *channel) { ...@@ -78,7 +90,10 @@ void addReplyPubsubUnsubscribed(client *c, robj *channel) {
/* Send the pubsub pattern subscription notification to the client. */ /* Send the pubsub pattern subscription notification to the client. */
void addReplyPubsubPatSubscribed(client *c, robj *pattern) { void addReplyPubsubPatSubscribed(client *c, robj *pattern) {
if (c->resp == 2)
addReply(c,shared.mbulkhdr[3]); addReply(c,shared.mbulkhdr[3]);
else
addReplyPushLen(c,3);
addReply(c,shared.psubscribebulk); addReply(c,shared.psubscribebulk);
addReplyBulk(c,pattern); addReplyBulk(c,pattern);
addReplyLongLong(c,clientSubscriptionsCount(c)); addReplyLongLong(c,clientSubscriptionsCount(c));
...@@ -89,7 +104,10 @@ void addReplyPubsubPatSubscribed(client *c, robj *pattern) { ...@@ -89,7 +104,10 @@ void addReplyPubsubPatSubscribed(client *c, robj *pattern) {
* punsubscribe command but there are no pattern to unsubscribe from: we * punsubscribe command but there are no pattern to unsubscribe from: we
* still send a notification. */ * still send a notification. */
void addReplyPubsubPatUnsubscribed(client *c, robj *pattern) { void addReplyPubsubPatUnsubscribed(client *c, robj *pattern) {
if (c->resp == 2)
addReply(c,shared.mbulkhdr[3]); addReply(c,shared.mbulkhdr[3]);
else
addReplyPushLen(c,3);
addReply(c,shared.punsubscribebulk); addReply(c,shared.punsubscribebulk);
if (pattern) if (pattern)
addReplyBulk(c,pattern); addReplyBulk(c,pattern);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment