Description
I'm using php websocket Bloatless V2.0, because my framework (Zend) only supports php 7.2.
i want to implement private chat like the example in StatusAplication to DemoAplication.
"The Status-Application includes an example for this: https://github.com/bloatless/php-websocket/blob/release/2.1.0/src/Application/StatusApplication.php#L49
Just use the $client->send() Method to send data to a specific client."
Private Chat in StatusAplication
` public function onConnect(Connection $client): void
{
$id = $client->getClientId();
$this->clients[$id] = $client;
$this->sendServerinfo($client);
}
private function sendServerinfo(Connection $client): void
{
if (count($this->clients) < 1) {
return;
}
$currentServerInfo = $this->serverInfo;
$currentServerInfo['clientCount'] = count($this->serverClients);
$currentServerInfo['clients'] = $this->serverClients;
$encodedData = $this->encodeData('serverInfo', $currentServerInfo);
$client->send($encodedData);
}
`
Send Chat in DemoAplikation
`
public function onConnect(Connection $client): void
{
$id = $client->getClientId();
$this->clients[$id] = $client;
}
private function actionEcho(string $text): void
{
$encodedData = $this->encodeData('echo', $text);
foreach ($this->clients as $sendto) {
$sendto->send($encodedData);
}
}
`
if my actionEcho input 2 parameters to be (string $tex, , Connection $client) like the example in sendServerinfo, the socket will error.
How can I add $client->send() in DemoAplication ?