| 302 | }; |
| 303 | |
| 304 | void UDPThreadFunc(void* userPtr, void* lsMemory) |
| 305 | { |
| 306 | printf("UDPThreadFunc thread started\n"); |
| 307 | // UDPThreadLocalStorage* localStorage = (UDPThreadLocalStorage*)lsMemory; |
| 308 | |
| 309 | UdpNetworkedInternalData* args = (UdpNetworkedInternalData*)userPtr; |
| 310 | // int workLeft = true; |
| 311 | b3Clock clock; |
| 312 | clock.reset(); |
| 313 | bool init = true; |
| 314 | if (init) |
| 315 | { |
| 316 | args->m_cs->lock(); |
| 317 | args->m_cs->setSharedParam(0, eUDPIsInitialized); |
| 318 | args->m_cs->unlock(); |
| 319 | |
| 320 | double deltaTimeInSeconds = 0; |
| 321 | |
| 322 | do |
| 323 | { |
| 324 | b3Clock::usleep(0); |
| 325 | |
| 326 | deltaTimeInSeconds += double(clock.getTimeMicroseconds()) / 1000000.; |
| 327 | |
| 328 | { |
| 329 | clock.reset(); |
| 330 | deltaTimeInSeconds = 0.f; |
| 331 | switch (args->m_cs->getSharedParam(1)) |
| 332 | { |
| 333 | case eUDP_ConnectRequest: |
| 334 | { |
| 335 | bool connected = args->connectUDP(); |
| 336 | if (connected) |
| 337 | { |
| 338 | args->m_cs->setSharedParam(1, eUDP_Connected); |
| 339 | } |
| 340 | else |
| 341 | { |
| 342 | args->m_cs->setSharedParam(1, eUDP_ConnectionFailed); |
| 343 | } |
| 344 | break; |
| 345 | } |
| 346 | default: |
| 347 | { |
| 348 | } |
| 349 | }; |
| 350 | |
| 351 | if (args->m_isConnected) |
| 352 | { |
| 353 | args->m_cs->lock(); |
| 354 | bool hasCommand = args->m_hasCommand; |
| 355 | args->m_cs->unlock(); |
| 356 | |
| 357 | if (hasCommand) |
| 358 | { |
| 359 | int sz = 0; |
| 360 | ENetPacket* packet = 0; |
| 361 |
nothing calls this directly
no test coverage detected