eee
This commit is contained in:
+34
-4
@@ -50,18 +50,48 @@ class Transport
|
||||
|
||||
|
||||
/**
|
||||
* @param int $fd
|
||||
* @param int $fd
|
||||
* @return void
|
||||
*/
|
||||
public function remove(int $fd): void
|
||||
{
|
||||
if ($this->clients[$fd]) {
|
||||
$this->clients[$fd]->ws->close();
|
||||
if ($this->has($fd)) {
|
||||
$this->clients[$fd]?->ws->close();
|
||||
}
|
||||
unset($this->clients[$fd]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $fd
|
||||
* @return Struct|null
|
||||
*/
|
||||
public function getClientId(int $fd): ?Struct
|
||||
{
|
||||
return array_find($this->clients, fn($client) => $client->fd == $fd);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $fd
|
||||
* @return Struct|null
|
||||
*/
|
||||
public function getUserId(int $fd): ?Struct
|
||||
{
|
||||
return $this->clients[$fd] ?? null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $fd
|
||||
* @return bool
|
||||
*/
|
||||
public function has(int $fd): bool
|
||||
{
|
||||
return isset($this->clients[$fd]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -71,7 +101,7 @@ class Transport
|
||||
foreach ($this->clients as $fd => $client) {
|
||||
$array[] = [
|
||||
'userId' => $fd,
|
||||
'nickname' => $client->user['nickname'],
|
||||
'nickname' => $client->user->getNickname(),
|
||||
];
|
||||
}
|
||||
return $array;
|
||||
|
||||
Reference in New Issue
Block a user