RejectedSoftware Forums

Sign up

Recurring server jobs

Hi,

I need a recurring server job to prepare data and broadcast the result to every connected clients through WebSockets. The job would execute every second ... for eternity. ;)

How should I proceed? I checked the Task example shipped with Vibe ... without success.

Thanks.

Re: Recurring server jobs

Am 11.02.2013 02:31, schrieb olivier henley:

Hi,

I need a recurring server job to prepare data and broadcast the result to every connected clients
through WebSockets. The job would execute every second ... for eternity. ;)

How should I proceed? I checked the Task example shipped with Vibe ... without success.

Thanks.

setTimer(&serverJob, 1.seconds(), true); should do the trick.

But maybe slightly better is starting a task that runs an endless loop with a sleep(1.seconds())
inside. Maybe also with one task per client to avoid slow clients slowing down other clients. This
approach would also avoid stacking up loads of tasks in the event that the client takes longer than
a second to process the request.

Btw., did the task example fail to work or did it just not help in finding a solution.

Re: Recurring server jobs

setTimer(&serverJob, 1.seconds(), true); should do the trick.

But maybe slightly better is starting a task that runs an endless loop with a sleep(1.seconds())
inside. Maybe also with one task per client to avoid slow clients slowing down other clients. This
approach would also avoid stacking up loads of tasks in the event that the client takes longer than
a second to process the request.

Btw., did the task example fail to work or did it just not help in finding a solution.

I'll use that strategy. Thx!