naprawa logiki i update stylu
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user