I like to reset the timer if i receive a message from udp but its not working (cant compile).
file.h
class MyThread : public ofThread {
udpConnection.Create();
udpConnection.Bind(11999);
udpConnection.SetNonBlocking(false);
// the thread function
void MyThread::threadedFunction() {
// start
while(isThreadRunning()) {
char udpMessage[1000];
udpConnection.Receive(udpMessage,1000);
string message=udpMessage;
scheduler.timer.reset();
}
}
}
};
class Scheduler: public ofThread {
public:
Scheduler() {
timer.setPeriodicEvent(1000000000); // this is 1 second in nanoseconds
startThread();
}
public:
ofTimer timer;
void threadedFunction() {
while(isThreadRunning()) {
timer.waitNext();
// Do your thing here. It will run once per second.
}
}
}
MyThread thread;
Scheduler scheduler;