本文整理汇总了C++中Connection::Connect方法的典型用法代码示例。如果您正苦于以下问题:C++ Connection::Connect方法的具体用法?C++ Connection::Connect怎么用?C++ Connection::Connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::Connect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Connect
//--------------------------------------------------------------------------
void Client::Connect(const VeChar8* pcName, const VeChar8* pcSrvIp,
VeUInt32 u32Port, const VeChar8* pcSrvPass)
{
VE_AUTO_LOCK_MUTEX(m_kMutex);
Connection* pkConnect = GetConnection(pcName);
if(pkConnect)
{
pkConnect->Connect(pcSrvIp, u32Port, pcSrvPass);
}
}
示例2: main
int main(int argc, char const *argv[])
{
using teamstyle16::Connection;
Connection *connection = Connection::Instance();
if (argc == 1)
connection->Connect();
else if (argc == 2)
connection->Connect(argv[1]);
else if (argc == 3)
connection->Connect(argv[1], argv[2]);
else
{
std::cerr << "Usage: " << argv[0] << " [host] [port]\n";
std::exit(EXIT_FAILURE);
}
try
{
connection->PrepareWork();
while (true)
{
connection->Update();
// If AIMain() returns, we assume the player want to update infos.
AIMain();
}
}
catch (const boost::system::system_error &e)
{
std::clog << "Connection lost: " << e.what() << std::endl;
std::exit(EXIT_FAILURE);
}
catch (const std::exception &e)
{
std::clog << "Exception caught: " << e.what() << std::endl;
std::exit(EXIT_FAILURE);
}
return 0;
}
示例3: main
int main(int argc, char** argv)
{
if (!Initialize())
{
cout << "Failed to initialize socket layer\n";
system("pause");
return -1;
}
if (!Bind(PORT))
{
cout << "Failed to bind listening socket\n";
system("pause");
Cleanup();
return -1;
}
Connection SendingSocket;
char choice;
char IP[16];
cout << "Host or Join (h/j)\n";
cin >> choice;
if (choice == 'h')
{
if (!ReceivingSocket.Accept())
{
cout << "Error while connecting to partner\n";
system("pause");
Cleanup();
return -1;
}
if(!SendingSocket.Accept())
{
cout << "Error while connecting to partner\n";
system("pause");
Cleanup();
return -1;
}
}
else
{
cout << "IP: ";
cin >> IP;
if (!SendingSocket.Connect(IP, PORT))
{
cout << "Error while connecting to partner\n";
cout << StringError() << endl;
system("pause");
Cleanup();
return -1;
}
if(!ReceivingSocket.Connect(IP, PORT))
{
cout << "Error while connecting to partner\n";
cout << StringError() << endl;
system("pause");
Cleanup();
return -1;
}
}
HRESULT result;
IAudioCaptureClient* capture_client = NULL;
IAudioClient* audio_client_capture = NULL;
IMMDevice* capture_device = NULL;
IMMDeviceEnumerator* enumerator = NULL;
IPropertyStore* propstore_capture = NULL;
PROPVARIANT pv_capture;
WAVEFORMATEX* wf_capture = NULL;
UINT32 packSize;
UINT32 availableFrames;
UINT32 timeIntervalForBuffer = 1000000;
UINT32 timeIntervalInMilliseconds = timeIntervalForBuffer / 10000;
BYTE* pData = NULL;
DWORD flags;
float index = 0;
result = CoInitialize(0);
if (FAILED(result))
{
printf("Failed to initialize\n");
goto Exit;
}
result = CoCreateInstance(
__uuidof(MMDeviceEnumerator), NULL,
CLSCTX_ALL, __uuidof(IMMDeviceEnumerator),
(void**)&enumerator);
if (FAILED(result))
{
printf("Failed to create device enumerator\n");
goto Exit;
}
result = enumerator->GetDefaultAudioEndpoint(eCapture, eCommunications, &capture_device);
if (FAILED(result))
{
printf("Failed to get capture endpoint handle\n");
goto Exit;
}
PropVariantInit(&pv_capture);
result = capture_device->OpenPropertyStore(STGM_READ, &propstore_capture);
if (FAILED(result))
//.........这里部分代码省略.........