示例#1
0
// Decide proper action and perform the job.
void Action::TakeAction(){
	// Do action following message type
	Packet pkt;
	std::string result;
	std::string temp;

	switch(m_GivenPkt.m_MsgType){

	case AP_REGISTRATION_REQUEST:
		InsertDatabase();
		SendResponseMessage(AP_REGISTRATION_RESPONSE, pkt);
		break;

	//case AP_REGISTRATION_RESPONSE:
		//break;

	case AP_STATE_UPDATE_REQUEST:
		UpdateDatabase();
		SendResponseMessage(AP_STATE_UPDATE_RESPONSE, pkt);
		break;

	//case AP_STATE_UPDATE_RESPONSE:
		//break;

	case AP_LIST_REQUEST:
		result = m_db->GetResult("select ID, IP, SSID from AP_Information;");

		//Parse the result by '|' mark
		//and make pkt context
		while(true)
		{
			temp = result.substr(0,result.find('|'));
			result.erase(0,result.find('|')+1);
			pkt.AddValue(AP_ID, temp);

			temp = result.substr(0,result.find('|'));
			result.erase(0,result.find('|')+1);
			pkt.AddValue(AP_IP, temp);

			temp = result.substr(0,result.find('|'));
			result.erase(0,result.find('|')+1);
			pkt.AddValue(AP_SSID, temp);

			if(result.length() < 1) break;
		}
		SendResponseMessage(AP_LIST_RESPONSE, pkt);
		break;

	default:
		break;
	}
}
示例#2
0
/***********************************************
 *void Report::SendAPUpdateRequest()
 *	Make AP Update Request
 *	Send Message to Manager
 *	Receive ACK from Manager
 ********************************************/
void Report::SendAPStateUpdateRequest(){
	//Make Message
	Packet pkt;
	pkt.DecideMessageType(AP_STATE_UPDATE_REQUEST);

	for(int type=AP_ID; type<=AP_CHANNEL; type++){
		pkt.AddValue(type, m_APInfo.GetAPInformation(type));
	}
	/*
	for(int type=AP_ID; type<=AP_DESCRIPTION; type++){
		pkt.AddValue(type, m_APInfo.GetAPInformation(type));
	}*/
	string msg = pkt.CreateMessage();

	//Send Message to OpenWinNet Manager
	cout << PrintTime() << "[S] AP_STATE_UPDATE REQUEST" << endl;
	m_sock.send(msg);
	msg.clear();
}