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

Function AttemptLocalConnection

main.cpp:105–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103\******************************************************************************************/
104
105bool AttemptLocalConnection()
106{
107 bool success = false;
108
109 NetworkClient * client = new NetworkClient(ResourceManager::get()->GetRGBControllers());
110
111 std::string titleString = "OpenRGB ";
112 titleString.append(VERSION_STRING);
113
114 client->SetName(titleString.c_str());
115 client->StartClient();
116
117 for(int timeout = 0; timeout < 10; timeout++)
118 {
119 if(client->GetConnected())
120 {
121 break;
122 }
123 std::this_thread::sleep_for(5ms);
124 }
125
126 if(!client->GetConnected())
127 {
128 client->StopClient();
129
130 delete client;
131
132 client = NULL;
133 }
134 else
135 {
136 ResourceManager::get()->RegisterNetworkClient(client);
137
138 success = true;
139
140 /*-----------------------------------------------------*\
141 | Wait up to 5 seconds for the client connection to |
142 | retrieve all controllers |
143 \*-----------------------------------------------------*/
144 for(int timeout = 0; timeout < 1000; timeout++)
145 {
146 if(client->GetOnline())
147 {
148 break;
149 }
150 std::this_thread::sleep_for(5ms);
151 }
152 }
153
154 return success;
155}
156
157/******************************************************************************************\
158* *

Callers 1

mainFunction · 0.85

Calls 8

StartClientMethod · 0.80
GetConnectedMethod · 0.80
StopClientMethod · 0.80
RegisterNetworkClientMethod · 0.80
getFunction · 0.50
appendMethod · 0.45
SetNameMethod · 0.45
GetOnlineMethod · 0.45

Tested by

no test coverage detected