Message sending by event source
Goodnight.
I installed and configured the WsServer and created a chat and so far everything works fine.
I need that after the client sends a message requesting data, he receives the update of the records with each new record change that occurs once per second, plus the onMessage event perfectly receives the message more when I send only the current message .
I inserted a loop and placed the `$conn->send` function inside this loop but the loop keeps script in continuous use and does not execute the send.
Well here goes the question is there any alternative for this?
I don't want to have to create a loop in javascripting sending messages every second.


```
$loop = \React\EventLoop\Factory::create();
        $WebSocketServer = new WsServer(new WebSocket());
        $WebSocketServer->enableKeepAlive($loop,0.1);
        $server = IoServer::factory(new HttpServer($WebSocketServer),8090);

        $server->run();
```

```
function onMessage(ConnectionInterface $from, $msg)
    {
        $response = null;
        $data = Json::decode($msg);
        if($data->subscribe == 1){

            if(in_array($data->time,$this->timeFrame) && in_array($data->market,$this->marketPlace)){
                    $response = Json::encode($this->cache->getItems(["$data->time-$data->market"])["$data->time-$data->market"]["data"]);
                    $from->send($response);                    
            }
        }
        // TODO: Implement onMessage() method.
    }
```

Hello guys - This problem has been solved.
**Solution**: ===========================================
```
function onMessage(ConnectionInterface $from, $msg)
    {
        $loop = React\EventLoop\Factory::create(); <------------
        $response = null;
        $data = Json::decode($msg);
        if($data->subscribe == 1){
            $loop->addPeriodicTimer(5, function () { <------------
                      if(in_array($data->time,$this->timeFrame) && in_array($data->market,$this->marketPlace)){
                              $response = Json::encode($this->cache->getItems(["$data->time-$data->market"])["$data->time-$data->market"]["data"]);
                              $from->send($response);                    
                      }
            }); <-----------------
        }
        $loop->run(); <---------------
        // TODO: Implement onMessage() method.
    }
```

=========================================
With the reactphp loop it reads the cache and sends the updated data to the client
**Solved problem.**