diff --git a/hueplusplus/UPnP.cpp b/hueplusplus/UPnP.cpp index f77e20b..0c41736 100755 --- a/hueplusplus/UPnP.cpp +++ b/hueplusplus/UPnP.cpp @@ -34,15 +34,17 @@ std::vector> UPnP::getDevices() { std::pair device; int start = s.find("LOCATION:") + 10; - std::cout << "Found \"LOCATION:\" at " << start << std::endl; device.first = s.substr(start, s.find("\r\n", start)-start); start = s.find("SERVER:") + 8; device.second = s.substr(start, s.find("\r\n", start) - start); - devices.push_back(device); - } - - // remove duplicates -> maybe include this in device filtering without the need of unique and stuff? - devices.erase(std::unique(devices.begin(), devices.end()), devices.end()); + if(std::find_if(devices.begin(), devices.end(), [&](const std::pair &item){return item.first == device.first;}) == devices.end()) + { + devices.push_back(device); + //std::cout << "Device: \t" << device.first << std::endl; + //std::cout << " \t" << device.second << std::endl; + } + } return devices; } +