本文整理汇总了C++中UserPtr::setFlag方法的典型用法代码示例。如果您正苦于以下问题:C++ UserPtr::setFlag方法的具体用法?C++ UserPtr::setFlag怎么用?C++ UserPtr::setFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserPtr
的用法示例。
在下文中一共展示了UserPtr::setFlag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadUsers
void MessageManager::loadUsers() {
try {
SimpleXML xml;
SettingsManager::loadSettingFile(xml, CONFIG_DIR, CONFIG_NAME);
auto cm = ClientManager::getInstance();
if (xml.findChild("Ignored")) {
xml.stepIn();
xml.resetCurrentChild();
if (xml.findChild("Users")) {
xml.stepIn();
while (xml.findChild("User")) {
UserPtr user = cm->getUser(CID(xml.getChildAttrib("CID")));
{
WLock(cm->getCS());
cm->addOfflineUser(user, xml.getChildAttrib("Nick"), xml.getChildAttrib("Hub"), (uint32_t)xml.getIntChildAttrib("LastSeen"));
}
WLock l(Ignorecs);
ignoredUsers.emplace(user);
user->setFlag(User::IGNORED);
}
xml.stepOut();
}
xml.stepOut();
}
}
catch (const Exception& e) {
LogManager::getInstance()->message(STRING_F(LOAD_FAILED_X, CONFIG_NAME % e.getError()), LogManager::LOG_ERROR);
}
}
示例2: storeIgnore
void MessageManager::storeIgnore(const UserPtr& aUser) {
{
WLock l(Ignorecs);
ignoredUsers.emplace(aUser);
}
aUser->setFlag(User::IGNORED);
dirty = true;
fire(MessageManagerListener::IgnoreAdded(), aUser);
}
示例3: createNode
/*
* Creates new (or update existing) node which is NOT added to our routing table
*/
Node::Ptr KBucket::createNode(const UserPtr& u, const string& ip, uint16_t port, bool update, bool isUdpKeyValid)
{
if(u->isSet(User::DHT)) // is this user already known in DHT?
{
Node::Ptr node = NULL;
// no online node found, try get from routing table
for(NodeList::iterator it = nodes.begin(); it != nodes.end(); ++it)
{
if(u->getCID() == (*it)->getUser()->getCID())
{
node = *it;
// put node at the end of the list
nodes.erase(it);
nodes.push_back(node);
break;
}
}
if(node == NULL && u->isOnline())
{
// try to get node from ClientManager (user can be online but not in our routing table)
// this fixes the bug with DHT node online twice
node = (Node*)ClientManager::getInstance()->findDHTNode(u->getCID());
node = node.get();
}
if(node != NULL)
{
// fine, node found, update it and return it
if(update)
{
string oldIp = node->getIdentity().getIp();
string oldPort = node->getIdentity().getUdpPort();
if(ip != oldIp || static_cast<uint16_t>(Util::toInt(oldPort)) != port)
{
node->setIpVerified(false);
// TODO: don't allow update when new IP already exists for different node
// erase old IP and remember new one
ipMap.erase(oldIp + ":" + oldPort);
ipMap.insert(ip + ":" + Util::toString(port));
}
if(!node->isIpVerified())
node->setIpVerified(isUdpKeyValid);
node->setAlive();
node->getIdentity().setIp(ip);
node->getIdentity().setUdpPort(Util::toString(port));
DHT::getInstance()->setDirty();
}
return node;
}
}
u->setFlag(User::DHT);
Node::Ptr node(new Node(u));
node->getIdentity().setIp(ip);
node->getIdentity().setUdpPort(Util::toString(port));
node->setIpVerified(isUdpKeyValid);
return node;
}