naprawa logiki i update stylu

This commit is contained in:
2026-03-08 18:49:35 +01:00
parent 533fcaa498
commit 1bed0e7774
3 changed files with 245 additions and 103 deletions
+6 -6
View File
@@ -65,7 +65,7 @@ class WebSocketServer implements MessageComponentInterface
{
$decodedMsg = json_decode($msg, true);
if (!$decodedMsg) {
$from->send("{\"error\"}: \"not or empty json\"");
$from->send("{\"error\": \"not or empty json\"}");
return;
}
$index = $this->getConnectionIndex($from);
@@ -75,10 +75,10 @@ class WebSocketServer implements MessageComponentInterface
$msgContent = $decodedMsg["message"] ?? null;
if ($msgContent) {
$this->sendToAllAuthenticated($this->connectionsData[$index]["username"], $msgContent);
$from->send("{\"success\"}: \"message send\"");
$from->send("{\"success\": \"message send\"}");
return;
}
$from->send("{\"error\"}: \"no message\"");
$from->send("{\"error\": \"no message\"}");
return;
}
@@ -87,13 +87,13 @@ class WebSocketServer implements MessageComponentInterface
$tokenUser = TokenHandler::getTokenOwnership($token);
if ($tokenUser) {
$this->connectionsData[$index]["username"] = $tokenUser;
$from->send("{\"success\"}: \"authenticated\"");
$from->send("{\"success\": \"authenticated\"}");
return;
}
$from->send("{\"error\"}: \"invalid token\"");
$from->send("{\"error\": \"invalid token\"}");
return;
}
$from->send("{\"error\"}: \"you are not authenticated\"");
$from->send("{\"error\": \"you are not authenticated\"}");
}
public function onClose(ConnectionInterface $conn): void