Created
May 1, 2019 12:59
-
-
Save BAHC/c10e63d275ea17c926c0626cee896924 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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