Exemplo n.º 1
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;
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
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;
}