Exemplo n.º 1
0
GameConnect::GameConnect(CommTimer* t, NetworkMonitor* m, int team, int player)
    : _timer(t), _monitor(m), _myTeamNumber(team),
      _haveRemoteGC(false), _gcTimestamp(0)
{
    _socket = new UDPSocket();
    setUpSocket();
}
Exemplo n.º 2
0
int getServSocket(const char *port) {
    struct addrinfo hints, *localhosts;
    int serverSocket;
    setHints(&hints);
    run(getaddrinfo(NULL, port, &hints, &localhosts));
    run(serverSocket = setUpSocket(localhosts));
    freeaddrinfo(localhosts);
    return serverSocket;
}
Exemplo n.º 3
0
/*
 * Constructor with IP Address Specified
 *
 * Creates ar_drone and takes char * IP address as argument
 * @param char * IP (IP address of the ARDrone)
 *
 */
void ar_drone(char * ip)
{
	IP_ADDRESS = ip;
	#ifdef printUpdates
		printf("Setting Up Drone @ %s\n", ip);
	#endif
	setUpSocket();
	count = 0;
}
Exemplo n.º 4
0
int main(int argc, char** argv)
{

    // this is called after the contructor!
    
    if(argc < 2)
    {
      printf("Expecting server's port number\n");
      return 1;
    }

    if(argc < 3)
    {
      printf("Expecting configuration filename\n");
      return 1;
    }

    headerPlug = malloc(sizeof(struct plug_node));
    printf("Reading configuration\n");
    readConfiguration(argv[2]);
    printf("Plugs found: %d\n",getListlength(headerPlug));

    printf("About to configure GPIO\n");
    // you must run this as root!!!
    // Configure GPIO 17 as output

    INP_GPIO(17);
    OUT_GPIO(17);
    
    socketId = setUpSocket(atoi(argv[1]));
    listenForData(socketId);
    
    /*
    plug_local_info * plug = &headerPlug->plug;
    sendSequence(plug->plug_code,TYPE_SWITCH_ON);
    sendSequence(plug->plug_code,TYPE_SWITCH_ON);
    sendSequence(plug->plug_code,TYPE_SWITCH_ON);
    */
    close(socketId);
}
Exemplo n.º 5
0
void Shortcut::stealthInteraction(QString path){
    // using the socket we will inform the main application the shortcuts have changed
    setUpSocket();
    int pathIndex = shortcutList->indexOfItemWithPath(path);

    // if there exist a shortcut to the file ask if the user wants to delete it
    bool toDelete = false;
    if (pathIndex != -1)
        toDelete = interaction->msgDoYouWantToDelete
                (path,shortcutList->getShortcut(pathIndex));


    if (toDelete){
        shortcutList->delShortcut(pathIndex);
        signalServer();
        return;
    }
    // do not allow creating shortcuts if one exists
    else if(toDelete == false && pathIndex != -1)
        return;

    // if the user inputs a wrong shortcut, ask again
    QString shortcut;
    do{
        shortcut = interaction->askForShortcut(this,path);
        if (!containsLetterAndNumbersOnly(shortcut)){
            interaction->shortcutIncorrect();
            continue;
        }

        break;
    }while(true);

    if (shortcut.compare("abort") == 0)
        return;


    bool shortcutExist = shortcutList->getIndex(shortcut);
    int answer = 0;
    if (shortcutExist == true)
        answer = interaction->msgShortcutExists();

    // the yes answer means that the shortcut should be replaced
    int addedSuccessfully;
    if (answer == QMessageBox::Yes || answer == 0){
        addedSuccessfully = shortcutList->addShortcut(shortcut, path);
    }
    else if(answer == QMessageBox::Cancel)
        return;

    if (addedSuccessfully == 0){
        interaction->msgShortcutAdded(shortcut);
        signalServer();
        return;
    }else if(addedSuccessfully == -1){
        interaction->msgShortcutError(shortcut);
        return;
    }

    // is this needed here?
    close();
}
Exemplo n.º 6
0
TeamConnect::TeamConnect(CommTimer* t, NetworkMonitor* m)
    : timer(t), monitor(m), myLastSeqNum(0)
{
    socket = new UDPSocket();
    setUpSocket();
}