Commit 090f86d6 authored by Mat's avatar Mat

parse en json la sortie message

parent e32f2752
......@@ -21,7 +21,7 @@
connection.onmessage = function(e)
{
console.log(e.data);
console.log(JSON.parse(e.data));
};
});
......
......@@ -39,7 +39,13 @@ class ChatHub implements MessageComponentInterface
{
// TODO: Implement onOpen() method.
echo "Un utilisateur s'est connecté\n";
$conn->send("Bienvenue sur le chat !");
$response = json_encode([
'type' => 'msg_server',
'author' => 'server',
'content' => "Bienvenue sur notre Web Socket Server",
'timestamp' => (new \DateTime())->getTimestamp()
]);
$conn->send($response);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment