//发布订阅 EventEmitter code // 当某配置发生变化时,通知到已订阅的客户端 void HocfgMgr::notifyChange( const string&; filename, int mtime ) const { string aliasPrefix = _F("%s_%s@", BOOK_HOCFG_ALIAS_PREFIX, filename.c_str()); CliMgr::AliasCursor alcr(aliasPrefix); CliBase *cli = NULL; vector vecCli; string msg("{"); StrParse::PutOneJson(msg, "notify", "cfg_change", true); StrParse::PutOneJson(msg, "filename", filename, true); StrParse::PutOneJson(msg, "mtime", mtime, false); msg += "}"; while ((cli = alcr.pop())) { IOHand* iohand = dynamic_cast(cli); if (NULL == iohand) { LOGWARN("NOTIFYCHANGE| msg=book from ocli| cli=%s| file=%s", cli->m_idProfile.c_str(), filename.c_str()); continue; } iohand->sendData(CMD_EVNOTIFY_REQ, ++m_seqid, msg.c_str(), msg.size(), true); } }
点赞 1

相关推荐

牛客网
牛客企业服务