-
-
Notifications
You must be signed in to change notification settings - Fork 158
Closed
Labels
Description
Hi,
I'd like to send periodic messages every 120s can't figure out how to tie timers and sockets together. I tried writing something like this but it's definitely not working. New to ReactPHP and would appreciate any guidance.
$socket->on('connection', function ($conn) use ($loop) {
$func = function () use ($conn) {$conn->close();};
$timer = $loop->addPeriodicTimer(120, function() use(&$conn));
$conn->on('data', function ($data) use ($loop, &$timer, $func) {
// do other stuff like connect to mysql to pull some data
$echo 'got here';
$connection->write('this is a periodic message');
});
});
$loop->run();
Reactions are currently unavailable