Пример #1
0
void sv::Bot::handler(Message msg)
{
	if(msg.sender != "SERVER")
	{
		std::string newmsg;

		if(msg.command == "JOIN")
		{
 			newmsg += "has joined " + channel;
			check_messages(msg.sender);
		}
		else if(msg.command == "PART" || msg.command == "QUIT")
		{						
			newmsg += "has quit " + channel;
		}	

		newmsg += "  " + msg.data;
		std::cout << msg.sender << channel << newmsg << std::endl;//dbg
		log.log_message(msg.sender, channel, newmsg);
		if(msg.command == "PRIVMSG")
		{
			handle_bot_commands(msg);
		}
	}
    else
    {        
        auto it = msg.botcommands.begin();
        if ((it = std::find(msg.botcommands.begin(), msg.botcommands.end(), "PING")) != msg.botcommands.end())
        {
            send("PONG " + *++it);
        }
    }
}
Пример #2
0
int main_chmon(int argc, char* argv[])
{
  if (argc!=2)
  {
    printf("Usage: chmon <port>\n");
    _exit(-1);
  }

  const char* devicename = argv[1];

  printf("Waiting for port to become available\n");
  while (access(devicename, F_OK)!=0)
  {
    sleep(1);
  }

  int fd = -1;
  printf("Waiting for access to port\n");
  while (1)
  {
    fd = open(devicename, O_RDWR | O_NOCTTY | O_NONBLOCK);
    if (fd>=0) break;
    perror("Waiting for port:");
  }
  
  arduino_speed(fd);

  // enter the main loop
  while (1)
  {
    // check for messages in the message file
    check_messages(fd);
    
    // get temperature and write it to file.
    get_temperature(fd);
    
    // read in the thermostat temperature
    get_thermostat();
    // update relay
    update_relay(fd);
    // update display
    update_display(fd);
  }
  return 0;
}
Пример #3
0
/*************************************************
* unread_room()
* this functions finds a room with unread messages
* and it returns its number
*************************************************/
int
unread_room()
{

    int i;
    room_t scratch;

    for (i = 0; i < MAXQUADS; i++) {
	scratch = readquad(i);
	if (i_may_read_forum(i)
	    && (skipping[i] == 0)
	    && (!is_zapped(i, &scratch))) {
	    if (check_messages(scratch, i) > 0) {
		return i;
	    }
	}
    }
    return 0;
}
Пример #4
0
void do_events(int sig)
{
	set_crash();
	set_date_time();
	check_reboot_shutdown();
	check_idle_and_timeout();
#ifdef NETLINKS
	check_nethangs_send_keepalives(); 
#endif
	check_messages(NULL,0);
	reset_alarm();
	transport();
	plugin_triggers(NULL, "");
	check_alarm();
	if (syspp->auto_save!=(-1))
		check_autosave();
	check_credit_updates();
	check_lynx();
	check_pings();
}
Пример #5
0
//Experiment with scanf
int main(void)
{
	init_all_systems();
	
	printf("Initialized.\r\n");

	uint32_t last_time = get_32bit_time();
	uint32_t curr_time;
	uint8_t chan = 0;
	got_rnb_cmd_flag = 0;
	
	while (1)
	{	
		check_messages(); //Not including this line seems to break recieving broadcast commands on this droplet. TODO: Why? Fix it.
	 	if(rnb_updated==1)
	 	{
			 
		 	//do stuff with last_good_rnb
		 	printf("{Range-> %f,Bearing-> %f,Heading-> %f,ID-> %u,\\[Lambda]->",
			 last_good_rnb.range, last_good_rnb.bearing*180/M_PI, 
			 last_good_rnb.heading*180/M_PI, last_good_rnb.id_number);
		printf("{");
		for(uint8_t emitter_num=0 ; emitter_num<6 ; emitter_num++)
		{
			printf("{");
			for(uint8_t sensor_num=0 ; sensor_num<6 ; sensor_num++)
			{
				printf("%u",last_good_rnb.brightness_matrix_ptr[emitter_num][sensor_num]);
				if(sensor_num<5) printf(",");
			}
			printf("}");
			if(emitter_num<5) printf(",");
		}
		printf("}}\r\n");
		rnb_updated=0;
	 	}
	}
}