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


C++ MessageHandler::MessageForSending方法代码示例

本文整理汇总了C++中MessageHandler::MessageForSending方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageHandler::MessageForSending方法的具体用法?C++ MessageHandler::MessageForSending怎么用?C++ MessageHandler::MessageForSending使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MessageHandler的用法示例。


在下文中一共展示了MessageHandler::MessageForSending方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

void main()
{
	sout << locker << "\n  Testing Socket Communicator Client"
		<< "\n ========================================\n" << unlocker;

	//Application::EnableVisualStyles();
	//Application::SetCompatibleTextRenderingDefault(false); 

	//// Create the main window and run it
	// Application::Run(gcnew SocketComm::DemoForm());

	try
	{
		EndPoint rep("127.0.0.1",2048);
		EndPoint sep("127.0.0.1",2049);

		// MsgSender_Proc is your sender's server message handling
		//   If you don't have sender server file handling don't 
		//   attach a file handler
		Communicator sndr(sep);
		sndr.setFileSource(".\\FilePostTest\\Sender\\");
		MsgHandler<MsgSender_Proc> smsgHandler;
		sndr.attachMsgHandler(&smsgHandler);
		sndr.listen();

		// The MsgReceiver_Proc and FileReceiver_Proc
		// should connect when they have a reply, so
		// don't connect the receiver - that's done
		// by your server code (see above)

		if(!sndr.connect("127.0.0.1",2048))
		{
			sout << "\n  failed to connect sndr\n\n";
			return;
		}

		sout<<"  start posting\n";

		// 		sndr.postMessage("first message");
		// 		sndr.postMessage("second message");
		// 		sndr.postMessage("third and longer message");
		// 		sndr.postMessage("fourth and still longer and most verbose message");
		// 		sndr.postFile("test.txt");
		// 		sndr.postFile("Project #4 Analysis.docx");
		// 		sndr.postFile("FormWithCppThread.zip");
		//sndr.postFile("notepad.exe");
		//sndr.postMessage("quit");

		MessageHandler mh;
		Message msg = mh.MessageForSending(MsgType::Dependency);

		sndr.postMessage(msg.ToString());

		_getche();


		sout << locker << "\n  Socket connection count = " 
			<< sndr.getSocketConnectionCount() << unlocker;

		sout << "\n\n  press key to exit:  ";
		sout.flush();
		sout << "\n\n";
		//    rcvr.disconnect();
		sndr.disconnect();

	}
	catch(std::exception& ex)
	{
		sout << locker << "\n  " << ex.what() << "\n\n" << unlocker;
	}
}
开发者ID:Ider,项目名称:SU-Courses,代码行数:71,代码来源:ClientProcess.cpp


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