We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 ?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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 ?
The text was updated successfully, but these errors were encountered: