/* */ #include "DefaultPeerListProcessor.h" #include "List.h" #include "Dictionary.h" #include "Data.h" bool DefaultPeerListProcessor::canHandle(const MetaEntry* peersEntry) const { const List* peersList = dynamic_cast(peersEntry); return peersList != 0; } Peers DefaultPeerListProcessor::extractPeer(const MetaEntry* peersEntry) { Peers peers; const List* peersList = dynamic_cast(peersEntry); if(!peersList) { return peers; } const MetaList& metaList = peersList->getList(); for(MetaList::const_iterator itr = metaList.begin(); itr != metaList.end(); itr++) { const Dictionary* peerDic = dynamic_cast(*itr); if(!peerDic) { break; } const Data* ip = dynamic_cast(peerDic->get("ip")); const Data* port = dynamic_cast(peerDic->get("port")); if(!ip || !port || !port->isNumber()) { continue; } PeerHandle peer = new Peer(ip->toString(), port->toInt()); peers.push_back(peer); } return peers; }