当前位置: 首页>>代码示例>>C++>>正文


C++ Connection::Connect方法代码示例

本文整理汇总了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);
	}
}
开发者ID:snailwork,项目名称:Texas-cs,代码行数:11,代码来源:Client.cpp

示例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;
}
开发者ID:Alex142857,项目名称:teamstyle16,代码行数:41,代码来源:main.cpp

示例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))
//.........这里部分代码省略.........
开发者ID:VLatunoV,项目名称:AudioClient,代码行数:101,代码来源:main.cpp


注:本文中的Connection::Connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。