Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timer within launched loop doesn't work #31

Closed
jjsaunier opened this issue Jul 4, 2015 · 3 comments
Closed

Add timer within launched loop doesn't work #31

jjsaunier opened this issue Jul 4, 2015 · 3 comments

Comments

@jjsaunier
Copy link

Hey,

I'm making face to a problem, i need to dynamcally attach timer. I'm on the context of websocket server (on top of ratchet) and i would use timer to emit message.

So i have created a component to attach timer on specific connection. But the callback is just played once :(

It's the expected behavior ? Am i on the wrong to achieve that ?

Thanks

@WyriHaximus
Copy link
Member

The loop has two timers. A one-off timer that's named addTimer for a single time call. And addPeriodicTimer for repeating calls. My guess if that you're using addTimer while you are expecting addPeriodicTimer.

@jjsaunier
Copy link
Author

You are right. I don't why i'm digging with "timer". 😫

Thank you ;)

@WyriHaximus
Copy link
Member

Cheers. Forgot to add this but the first argument passed into a timer is the timer itself. You can stop it like this: $timer->cancel(); (You get the same $timer return when adding it to the loop.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants