function disconnect($socket)
{
$found = null;
$n = count($this->users);
for ($i = 0; $i < $n; $i++) {
if ($this->users[$i]->socket == $socket) {
$found = $i;
break;
}
}
if (!is_null($found)) {
array_splice($this->users, $found, 1);
}
$index = array_search($socket, $this->sockets);
socket_close($socket);
$this->log($socket . " DISCONNECTED!");
if ($index >= 0) {
array_splice($this->sockets, $index, 1);
}
}