Skip to content

Instantly share code, notes, and snippets.

@BAHC
Created May 1, 2019 12:59
Show Gist options
  • Save BAHC/c10e63d275ea17c926c0626cee896924 to your computer and use it in GitHub Desktop.
Save BAHC/c10e63d275ea17c926c0626cee896924 to your computer and use it in GitHub Desktop.
public function __construct()
{
$this->clients = new \SplObjectStorage;
$this->connectedUsers = [];
$this->connectedIDs = [];
$this->IDs = 0;
}
public function onOpen(ConnectionInterface $conn)
{
// Store the new connection to send messages to later
$this->clients->attach($conn);
$this->connectedUsers [$conn->resourceId] = $conn;
$this->connectedIDs[++$this->IDs] = $conn->resourceId; // а откуда мы берём owner ?
echo "New connection! ({$conn->resourceId})\n";
$conn->send(json_encode({'owner': $this->IDs, 'status': connected}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment