예제 #1
0
void    Engine:: enterMainLoop()  {
    
    doCapGtimeCalcDt();
    m_delayTime = gameTime;
    
    while ( ! quit ) {
        doCapGtimeCalcDt();
        doScripts();
        doInput();
        doUpdate();
        doCollision();
        doDelay();
        doRender();
    }
}
예제 #2
0
UtlBoolean MprDelay::doProcessFrame(MpBufPtr inBufs[],
                                    MpBufPtr outBufs[],
                                    int inBufsSize,
                                    int outBufsSize,
                                    UtlBoolean isEnabled,
                                    int samplesPerFrame,
                                    int samplesPerSecond)
{
   // We're disabled or have nothing to process.
   if ( outBufsSize == 0 || inBufsSize == 0 )
   {
      return TRUE;
   }
   if (!isEnabled)
   {
      outBufs[0] = inBufs[0];
      return TRUE;
   }

   return doDelay(inBufs[0], outBufs[0], samplesPerFrame, samplesPerSecond);
}
예제 #3
0
파일: sockTestSrv.C 프로젝트: jimix/k42
int
main(int argc, char *argv[])
{
    int rc, infinite = 0, count=0;
    FDType serverFD;

    processArgs(argc, argv);

    if (server) {
        serverLoop();
        fprintf(stderr, "oops server loop terminated\n");
    }

    if (!host) {
	usage();
        fprintf(stderr, "sockTestSrv: FAIL: please use -h to specify host\n");
        return 1;
    }
    printf("host = %s\n", host);

    if (!port) {
        fprintf(stderr, "must specify server port with -p\n");
        return 0;
    }
    printf("port = %d\n", port);


    rc = 1;
    if (clientAction == CMD) {
        serverFD = clientConnect(host, port);
        if (serverFD == -1) return 0;
        rc = cmdClient(serverFD);
        close(serverFD);
    } else if (clientAction == ECHO) {
        if (repeatCount == 0) { infinite = 1; count = 0; }
        while (1) {
            if (!infinite && repeatCount==0) {
                break;
            }
            serverFD = clientConnect(host, port);
            if (serverFD == -1) return 0;
            rc = echoClient(serverFD);
            close(serverFD);
            if (!infinite) {
                repeatCount--;
                write(1,".",1);
                if (repeatCount) {
                    doDelay();
                }
            } else {
                count++;
                if (count == 1000) {  write(1,".",1); count=0; }
                doDelay();
            }
        }
    } else {
        fprintf(stderr, "unknown client action\n");
        rc = 0;
    }
    return rc;
}
예제 #4
0
파일: sockTestSrv.C 프로젝트: jimix/k42
int cmdClient(FDType fd)
{
    int strLen = strlen(cmdString);
    int i,count,responseLen,offset;
    const int InBufSize = 1048;
    char inBuf[InBufSize];
    char *response = NULL;
    int infinite = 0, bytesToRead, bytesRead, requests = 0;
    char cmd[MESG_SIZE];

    memcpy(cmd, cmdString, strLen);
    cmd[strLen]='\n';
    cmd[strLen+1]='\0';

    printf("cmd to issue = %s", cmd);
    printf("repeat count = %d\n", repeatCount);
    printf("delay        = %d\n", delay);


    if (repeatCount == 0) { infinite = 1; requests = 0; }

    while (1) {
        if (!infinite && repeatCount==0) break;
        // send
        count = write(fd, cmd, strLen+1);
        if (count != strLen+1 ) {
            printf("write failed: count = %d != strLen+1 = %d\n",
                   count, strLen+1);
            return 0;
        }

        // recieve len of response and any data that will fit in inBuf
        count = read(fd,inBuf,InBufSize);
        if (count <= 0) {
            printf("read failed: count=%d\n",count);
            return 0;
        }
        i=0;
        while (inBuf[i]!=',') i++;
        inBuf[i]='\0';
        responseLen = atoi(inBuf);
        bytesToRead = responseLen;
        i++;

//        printf("count=%d responseLen=%d\n", count, responseLen);

        // prepare memory for entire response
        if (response == NULL) response = (char *)malloc(responseLen+1);
        response[responseLen]='\0';
        // copy and part of the response that ended up in inBuf
        memcpy(response, &inBuf[i], count-i);
        offset = count-i;
        responseLen -= offset;
        bytesRead = offset;

//        printf("responseLen=%d offset=%d i=%d\n", responseLen, offset, i);

        // get any remaining data
        while (responseLen) {
            count = read(fd,(char *)(response + offset),responseLen);
//            printf("after read count = %d reponseLen = %d offset=%d\n",
//                   count, responseLen, offset);
            if (count == -1) {
                printf("read failed: count=%d\n", count);
                return 0;
            }
            offset += count;
            responseLen -= count;
            bytesRead += count;
        }

        if (bytesToRead != bytesRead) {
            printf("read of data failed bytesToRead = %d != bytesRead = %d\n",
                   bytesToRead, bytesRead);
        }

//        printf("response %d: %s\n", responseLen, response);
        if (!infinite) {
            printf("bytesRead = %d\n", bytesRead);
            repeatCount--;
            if (repeatCount) {
                doDelay();
            }
        } else {
            requests++;
            if (requests == 1000) {
                requests = 0;
                write(1,"*",1);
            }
            doDelay();
        }
    }
    if (response) free(response);

    return 0;
}