MCPcopy Create free account
hub / github.com/ValveSoftware/GameNetworkingSockets / Run

Method Run

examples/example_chat.cpp:557–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

555{
556public:
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 }
580private:
581
582 HSteamNetConnection m_hConnection;

Callers

nothing calls this directly

Calls 6

SteamNetworkingSocketsFunction · 0.85
SetPtrMethod · 0.80
ConnectByIPAddressMethod · 0.80
PrintfFunction · 0.70
FatalErrorFunction · 0.70
ToStringMethod · 0.45

Tested by

no test coverage detected