MCPcopy Create free account
hub / github.com/acl-dev/acl / check_channel

Method check_channel

lib_acl_cpp/src/redis/redis_pubsub.cpp:286–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286int redis_pubsub::check_channel(const redis_result* obj, const char* cmd,
287 const char* channel)
288{
289 if (obj->get_type() != REDIS_RESULT_ARRAY) {
290 return -1;
291 }
292
293 const redis_result* rr = obj->get_child(0);
294 if (rr == NULL || rr->get_type() != REDIS_RESULT_STRING) {
295 return -1;
296 }
297
298 string buf;
299 rr->argv_to_string(buf);
300 if (strcasecmp(buf.c_str(), cmd) != 0) {
301 acl::string tmp;
302 obj->to_string(tmp);
303 logger_warn("invalid cmd=%s, %s, result=%s",
304 buf.c_str(), cmd, tmp.c_str());
305 return -1;
306 }
307
308 rr = obj->get_child(1);
309 if (rr == NULL || rr->get_type() != REDIS_RESULT_STRING) {
310 return -1;
311 }
312
313 buf.clear();
314 rr->argv_to_string(buf);
315 if (strcasecmp(buf.c_str(), channel) != 0) {
316 acl::string tmp;
317 obj->to_string(tmp);
318 logger_warn("invalid channel=%s, %s, result=%s",
319 buf.c_str(), channel, tmp.c_str());
320 return -1;
321 }
322
323 rr = obj->get_child(2);
324 if (rr == NULL || rr->get_type() != REDIS_RESULT_INTEGER) {
325 return -1;
326 }
327
328 return rr->get_integer();
329}
330
331bool redis_pubsub::get_message(string& channel, string& msg,
332 string* message_type /* = NULL */, string* pattern /* = NULL */,

Callers

nothing calls this directly

Calls 7

get_typeMethod · 0.45
get_childMethod · 0.45
argv_to_stringMethod · 0.45
c_strMethod · 0.45
to_stringMethod · 0.45
clearMethod · 0.45
get_integerMethod · 0.45

Tested by

no test coverage detected