[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] AGENTS & TIMERS
Prats Albert wrote:
>
> Hi ns-users!!
>
> I know that it's possible to define 2 timers within ang agent class. But I
> want that each timer invokes a different timeout procedure. It's possible??
>
> If I make this it gives me an error.
There are several ways of doing this, anything from a switch statement
to function pointer. But the easiest way is to have to separate classes.
(shown) Hope this helps.
-Will
...
class MyTimer : public TimerHandler {
public:
MyTimer();
protected:
virtual void expire(Event * e);
MyAgent * agent_;
};
void MyTimer::expire(Event * e)
{
agent_->FunctionOne();
}
...
class MyTimer2 : public TimerHandler {
public:
MyTimer2();
protected:
virtual void expire(Event * e);
MyAgent * agent_;
};
void MyTimer2::expire(Event * e)
{
agent_->FunctionTwo();
}