本文整理汇总了C++中SearchResult::toSR方法的典型用法代码示例。如果您正苦于以下问题:C++ SearchResult::toSR方法的具体用法?C++ SearchResult::toSR怎么用?C++ SearchResult::toSR使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchResult
的用法示例。
在下文中一共展示了SearchResult::toSR方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on
void ClientManager::on(NmdcSearch, Client* aClient, const string& aSeeker, int aSearchType, int64_t aSize,
int aFileType, const string& aString) throw()
{
Speaker<ClientManagerListener>::fire(ClientManagerListener::IncomingSearch(), aString);
bool isPassive = (aSeeker.compare(0, 4, "Hub:") == 0);
// We don't wan't to answer passive searches if we're in passive mode...
if(isPassive && !ClientManager::getInstance()->isActive()) {
return;
}
SearchResult::List l;
ShareManager::getInstance()->search(l, aString, aSearchType, aSize, aFileType, aClient, isPassive ? 5 : 10);
// dcdebug("Found %d items (%s)\n", l.size(), aString.c_str());
if(l.size() > 0) {
if(isPassive) {
string name = aSeeker.substr(4);
// Good, we have a passive seeker, those are easier...
string str;
for(SearchResult::Iter i = l.begin(); i != l.end(); ++i) {
SearchResult* sr = *i;
str += sr->toSR(*aClient);
str[str.length()-1] = 5;
str += name;
str += '|';
sr->decRef();
}
if(str.size() > 0)
aClient->send(str);
} else {
try {
string ip, file;
uint16_t port = 0;
Util::decodeUrl(aSeeker, ip, port, file);
ip = Socket::resolve(ip);
// Temporary fix to avoid spamming hublist.org and dcpp.net
if(ip == "70.85.55.252" || ip == "207.44.220.108") {
LogManager::getInstance()->message("Someone is trying to use your client to spam " + ip + ", please urge hub owner to fix this");
return;
}
if(port == 0)
port = 412;
for(SearchResult::Iter i = l.begin(); i != l.end(); ++i) {
SearchResult* sr = *i;
udp.writeTo(ip, port, sr->toSR(*aClient));
sr->decRef();
}
} catch(const SocketException& /* e */) {
dcdebug("Search caught error\n");
}
}
}
}