You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.
I have several JS clients connected to websocket server. They are organized into channels (I store Node objects).
Now one of the clients (client A) disconnects.
In PHP server, I'm listening to 'close' event and want to tell other clients in that room that A has disconnected.
Here's my code:
$this->websocket->on('close', function (Bucket$bucket) {
// Get list of connected channel clients// Make sure to remove disconnected client (client A) from the list.$this->websocket->broadcastIf(function ($currentNode) use ($channelNodes) {
$result = false;
/** @var \Hoa\Websocket\Node $currentNode *//** @var \Hoa\Websocket\Node $node */foreach ($channelNodesas$node) {
if ($currentNode->getId() === $node->getId()) {
$result = true;
break;
}
}
return$result;
}, Json::encode($data));
});
However, when I do this I get this message:
[2017-09-13 11:50:36.335700] Try to change the stream resource with an invalid one; given unknown type. at /Users/undsoft/htdocs/freelancer/vendor/hoa/stream/Stream.php. Line 412
#0 /Users/undsoft/htdocs/freelancer/vendor/hoa/socket/Connection/Handler.php(276): Hoa\Stream\Stream->_setStream(Resource id #170)
#1 /Users/undsoft/htdocs/freelancer/vendor/hoa/websocket/Connection.php(566): Hoa\Socket\Connection\Handler->Hoa\Socket\Connection\{closure}(1, true)
#2 [internal function]: Hoa\Websocket\Connection->send('{"type":"connec...', Object(Hoa\Websocket\Node))
#3 /Users/undsoft/htdocs/freelancer/vendor/hoa/socket/Connection/Handler.php(336): call_user_func_array(Array, Array)
#4 /Users/undsoft/htdocs/freelancer/websockets/classes/Handler.php(345): Hoa\Socket\Connection\Handler->broadcastIf(Object(Closure), '{"type":"connec...')
Any ideas?
The text was updated successfully, but these errors were encountered:
I can work around it by marking client as disconnect in on close and then actually telling everybody about it in on message.
Still would be nice to fix this or at least document it.
Hi,
I have several JS clients connected to websocket server. They are organized into channels (I store Node objects).
Now one of the clients (client A) disconnects.
In PHP server, I'm listening to 'close' event and want to tell other clients in that room that A has disconnected.
Here's my code:
However, when I do this I get this message:
Any ideas?
The text was updated successfully, but these errors were encountered: