this is he onOpen() function :
private $clients;
public function __construct()
{
$this->clients = new SplObjectStorage();
}
public function onOpen(ConnectionInterface $conn)
{
$cookie = $myCookieValue = $conn->httpRequest->getHeaders()['Cookie'][0];
$sessionid = explode('=', $cookie)[1];
session_id($sessionid);
session_start();
$data = $_SESSION;
session_write_close();
$email = $data["_sf2_attributes"]['email'];
$id = $data["_sf2_attributes"]['id'];
// Store client data in SplObjectStorage
$this->clients->attach($conn, [
'id' => $id,
'email' => $email,
]);
echo "New connection: " . $conn->resourceId . " there is ". sizeof($this->clients) ." client\n";
}
i want to make a private chat application with symfony
but the problem is that when i make 2 connection to this webSocket server it only detect the first client this is the output:
New connection: 566 there is 1 client
also when i send msg with the second client the server intercept the msg i want to know why only the first client is stored in the array "$this->clients"