MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / getBridge

Method getBridge

dependencies/hueplusplus-1.0.0/src/Bridge.cpp:78–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78Bridge BridgeFinder::getBridge(const BridgeIdentification& identification, bool sharedState)
79{
80 std::string normalizedMac = normalizeMac(identification.mac);
81 auto pos = usernames.find(normalizedMac);
82 auto key = clientkeys.find(normalizedMac);
83 if (pos != usernames.end())
84 {
85 if (key != clientkeys.end())
86 {
87 return Bridge(identification.ip, identification.port, pos->second, http_handler, key->second,
88 std::chrono::seconds(10), sharedState);
89 }
90 else
91 {
92 return Bridge(identification.ip, identification.port, pos->second, http_handler, "",
93 std::chrono::seconds(10), sharedState);
94 }
95 }
96 Bridge bridge(identification.ip, identification.port, "", http_handler, "", std::chrono::seconds(10), sharedState);
97 bridge.requestUsername();
98 if (bridge.getUsername().empty())
99 {
100 std::cerr << "Failed to request username for ip " << identification.ip << std::endl;
101 throw HueException(CURRENT_FILE_INFO, "Failed to request username!");
102 }
103 addUsername(normalizedMac, bridge.getUsername());
104 addClientKey(normalizedMac, bridge.getClientKey());
105
106 return bridge;
107}
108
109void BridgeFinder::addUsername(const std::string& mac, const std::string& username)
110{

Callers 7

TEST_FFunction · 0.80
connectToBridgeFunction · 0.80
connectToBridgeFunction · 0.80
snippet1Function · 0.80
snippet3Function · 0.80
connectToBridgeFunction · 0.80

Calls 8

BridgeClass · 0.85
HueExceptionClass · 0.85
requestUsernameMethod · 0.80
getUsernameMethod · 0.80
getClientKeyMethod · 0.80
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by 1

TEST_FFunction · 0.64