| 158 | } |
| 159 | |
| 160 | int redis_pubsub::subop_result(const char* cmd, |
| 161 | const std::vector<const char*>& channels) |
| 162 | { |
| 163 | int nchannels = 0, ret; |
| 164 | size_t i = 0; |
| 165 | do { |
| 166 | const redis_result* res = run(); |
| 167 | if (res == NULL || res->get_type() != REDIS_RESULT_ARRAY) { |
| 168 | return -1; |
| 169 | } |
| 170 | |
| 171 | // clear request, so in next loop we just read the data from |
| 172 | // redis-server that the data maybe the message to be skipped |
| 173 | clear_request(); |
| 174 | |
| 175 | const redis_result* o = res->get_child(0); |
| 176 | if (o == NULL || o->get_type() != REDIS_RESULT_STRING) { |
| 177 | return -1; |
| 178 | } |
| 179 | |
| 180 | string tmp; |
| 181 | o->argv_to_string(tmp); |
| 182 | // just skip message in subscribe process |
| 183 | if (tmp.equal("message", false) || tmp.equal("pmessage", false)) { |
| 184 | continue; |
| 185 | } |
| 186 | |
| 187 | if ((ret = check_channel(res, cmd, channels[i])) < 0) { |
| 188 | return -1; |
| 189 | } |
| 190 | |
| 191 | if (ret > nchannels) { |
| 192 | nchannels = ret; |
| 193 | } |
| 194 | |
| 195 | i++; |
| 196 | |
| 197 | } while (i < channels.size()); |
| 198 | |
| 199 | return nchannels; |
| 200 | } |
| 201 | |
| 202 | int redis_pubsub::subop(const char* cmd, const std::vector<const char*>& channels) |
| 203 | { |