Exemple #1
0
int main(int argc, char * argv[]){

	//configure the comms
	MOOS::MOOSAsyncCommClient Comms;
	Comms.SetOnMailCallBack(OnMail,&Comms);
	Comms.SetOnConnectCallBack(OnConnect,&Comms);

	//start the comms running
	Comms.Run("localhost",9000,"EX20");

	for(;;){
		MOOSPause(1000);
		Comms.Notify("Greeting","Hello");
	}
	return 0;
}
int main(int argc, char * argv[])
{
	MOOS::MOOSAsyncCommClient C;
	MOOS::CommandLineParser P(argc,argv);


	C.AddMessageCallback("CallbackA","X",func,NULL);
	C.AddMessageCallback("CallbackB","Y",func,NULL);
	C.SetOnConnectCallBack(on_connect, &C);
	C.Run("localhost",9000,"reg_test");

	std::cerr<<"now run \"umm -p=X@2,Y@2\n\"";

	while(1)
	{
		std::cerr<<"waiting 5 seconds\n";
		MOOSPause(5000);
		std::cerr<<"unregistering for everything\n";
		C.UnRegister("*","*");
		std::cerr<<"waiting 5 seconds\n";
		MOOSPause(5000);
		std::cerr<<"registering for \"X\" and \"Y\"\n";
		C.Register("X");
		C.Register("Y");
	}



}
Exemple #3
0
int main(int argc, char * argv[])
{
	MOOS::CommandLineParser P(argc,argv);

	std::string db_host = "localhost";
	P.GetVariable("--moos_host",db_host);

	int db_port = 9000;
	P.GetVariable("--moos_port",db_port);

	std::string my_name = "Practice App 03";
	P.GetVariable("--moos_name",my_name);

	MOOS::MOOSAsyncCommClient Comms;

	Comms.SetOnMailCallBack(OnMail,&Comms);
	Comms.SetOnConnectCallBack(OnConnect,&Comms);

	Comms.Run(db_host,db_port,my_name);

	std::vector<unsigned char> X(100);
	int Y = 0;

	while(1)
	{
		MOOSPause(1000);
		Comms.Notify("X",X);
		Comms.Notify("Y",Y++);
	}
	return 0;
}
int main(int argc, char * argv[])
{
	MOOS::MOOSAsyncCommClient C;
	MOOS::CommandLineParser P(argc,argv);

	if(P.GetFlag("-h","--help"))
	{
		PrintHelpAndExit();
	}

	InterestedParty aClass;

	//C.AddMessageRouteToActiveQueue("CallbackA","la",func,NULL);
	//C.AddMessageRouteToActiveQueue("CallbackB","di",func,NULL);
	//C.AddMessageRouteToActiveQueue("CallbackC","di",func_alt,NULL);
	//C.AddMessageRouteToActiveQueue("Wildcard","*", func_wild,NULL);
	//C.AddMessageRouteToActiveQueue("ClassMember","la", &aClass,&InterestedParty::HandleMessageA);
	//C.AddMessageRouteToActiveQueue("ClassMember","di", &aClass,&InterestedParty::HandleMessageB);
	//C.AddWildcardActiveQueue("WCA","*", func_wildcard,NULL);

	//C.PrintMessageToActiveQueueRouting();


	MOOS::MessageQueueAccumulator Acc;

	std::vector<std::string> Names;
	Names.push_back("di");
	Names.push_back("la");

	Acc.Configure(Names);
	C.AddMessageRouteToActiveQueue("Accumulator","di", &Acc,&MOOS::MessageQueueAccumulator::AddMessage);
	C.AddMessageRouteToActiveQueue("Accumulator","la", &Acc,&MOOS::MessageQueueAccumulator::AddMessage);
	Acc.SetCallback(&aClass,&InterestedParty::HandleMessageSet);



	//C.lala();
	C.SetOnConnectCallBack(on_connect, &C);
	C.Run("localhost",9000,"queue_test");


	unsigned int j = 0;
	while(++j)
	{
		if(j%100==0)
		{
			C.AddWildcardActiveQueue("WCB","d*", &aClass,&InterestedParty::HandleMessageC);
			C.PrintMessageToActiveQueueRouting();
		}
		MOOSPause(100);
		continue;
	}




}
Exemple #5
0
int main(int argc, char * argv[]){

	//understand the command line
	MOOS::CommandLineParser P(argc,argv);

	std::string db_host="localhost";
	P.GetVariable("--moos_host",db_host);

	int db_port=9000;
	P.GetVariable("--moos_port",db_port);

	std::string my_name ="ex50";
	P.GetVariable("--moos_name",my_name);

	//configure the comms
	MOOS::MOOSAsyncCommClient Comms;
	Comms.SetOnConnectCallBack(OnConnect,&Comms);

	//here we add per message callbacks
	//first parameter is the channel nick-name, then the function
	//to call, then a parameter we want passed when callback is
	//invoked
	Comms.AddMessageCallback("callbackA","V1",funcA,NULL);

	//add a default handler
	Comms.AddMessageCallback("default","*",DefaultMail,NULL);

	//start the comms running
	Comms.Run(db_host,db_port,my_name);

	//for ever loop sending data
	std::vector<unsigned char> data(1000);
	for(;;){
		MOOSPause(10);
		Comms.Notify("V1",data); //for funcA
		Comms.Notify("V2","This is stuff"); //will be caught by default
	}
	return 0;
}