IDEA for list of connected users
On the client side I use this to add the user to the list.

```
socket.addEventListener('open', (e) => {
	socket.send(JSON.stringify({
		type: 'newUserConnected',
		id: <?= $userId ?>,
		name: '<?= $userNick ?>'
	}));
});
```

Server side:

```
public function onMessage(ConnectionInterface $connId, $data)
{
    $resultJson = json_decode($data);
    
    if (isset($resultJson->type)) {
    
	    switch ($resultJson->type) {
		    case 'newUserConnected':
			    $dataJson = json_encode(['type' => 'newUserConnected', 'name' => $resultJson->name, 'id' => $resultJson->id]);
    
			    foreach ($this->clients as $client) {
				    $client->send($dataJson);
			    }
			    break;
	    }
    }
}
```

Client side:

```
socket.addEventListener('message', (e) => {
  const data = JSON.parse(e.data);
  
  let output = '';
  
  if (data.type === 'newUserConnected') {
	  output = `
		  <li>
			  <p class="m-0 overflow-hidden text-break">${data.name}</p>
		  </li>
		  `;
  
	  $('#chat-users').append(output);
  }

  output = '';
});
```

this part of adding the user to the list is fine, but on the client side I don't have an event to fire for the server and the server to update the list of disconnected ones.

I need ideas on how to do this.