| 555 | { |
| 556 | public: |
| 557 | void Run( const SteamNetworkingIPAddr &serverAddr ) |
| 558 | { |
| 559 | // Select instance to use. For now we'll always use the default. |
| 560 | m_pInterface = SteamNetworkingSockets(); |
| 561 | |
| 562 | // Start connecting |
| 563 | char szAddr[ SteamNetworkingIPAddr::k_cchMaxString ]; |
| 564 | serverAddr.ToString( szAddr, sizeof(szAddr), true ); |
| 565 | Printf( "Connecting to chat server at %s", szAddr ); |
| 566 | SteamNetworkingConfigValue_t opt; |
| 567 | opt.SetPtr( k_ESteamNetworkingConfig_Callback_ConnectionStatusChanged, (void*)SteamNetConnectionStatusChangedCallback ); |
| 568 | m_hConnection = m_pInterface->ConnectByIPAddress( serverAddr, 1, &opt ); |
| 569 | if ( m_hConnection == k_HSteamNetConnection_Invalid ) |
| 570 | FatalError( "Failed to create connection" ); |
| 571 | |
| 572 | while ( !g_bQuit ) |
| 573 | { |
| 574 | PollIncomingMessages(); |
| 575 | PollConnectionStateChanges(); |
| 576 | PollLocalUserInput(); |
| 577 | std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) ); |
| 578 | } |
| 579 | } |
| 580 | private: |
| 581 | |
| 582 | HSteamNetConnection m_hConnection; |
nothing calls this directly
no test coverage detected