本文整理汇总了C++中CClient::Connect方法的典型用法代码示例。如果您正苦于以下问题:C++ CClient::Connect方法的具体用法?C++ CClient::Connect怎么用?C++ CClient::Connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CClient
的用法示例。
在下文中一共展示了CClient::Connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char *argv[] )
{
unsigned int ip = 0;
if ( argc < 2 )
{
std::cout << "Error, no IP specified." << std::endl;
PrintUsage();
return EXIT_FAILURE;
}
ip = htonl( inet_addr( argv[1] ) );
if ( ip == INADDR_ANY || ip == INADDR_NONE )
{
std::cout << "Error, invalid IP." << std::endl;
PrintUsage();
return EXIT_FAILURE;
}
unsigned short port = DEFAULT_PORT;
if ( argc >= 3 )
{
if ( ( port = atoi( argv[2] ) ) == 0 )
port = DEFAULT_PORT;
}
std::cout << "Initializing SteamAPI..." << std::endl;
// this will find and load steamclient.dll for us
if ( !SteamAPI_Init() )
{
std::cout << "Fatal Error: Unable to init SteamAPI." << std::endl;
return EXIT_FAILURE;
}
std::cout << "Done!" << std::endl;
CreateInterfaceFn clientFactory = Sys_GetFactory( "steamclient" );
if ( !clientFactory )
{
// shouldn't ever happen, but if it does...
std::cout << "Fatal Error: Unable to get steamclient factory." << std::endl;
return EXIT_FAILURE;
}
CClient client;
if ( !client.Initialize( clientFactory ) )
return EXIT_FAILURE;
if ( !client.Connect( ip, port ) )
return EXIT_FAILURE;
while ( client.IsRunning() )
{
client.RunFrame();
Sleep( 5 );
}
return EXIT_SUCCESS;
}
示例2: main
int main()
{
CClient* myClient = new CClient();
myClient->Init();
myClient->Connect("127.0.0.1",60000);
while(1)
{
//.. do stuff
myClient->Update();
}
myClient->Destroy();
delete myClient;
return 0;
}