Make a WebSocket example work with crawler.yt.lemnoslife.com

This commit is contained in:
Benjamin_Loison committed 2023-01-31 01:05:09 +01:00
1 parent 155d372186
commit 0dba8e0c7d
2 files changed
+6 -13

No files matched your search

+5 -11
View File
@@ -7,8 +7,7 @@ use Ratchet\ConnectionInterface;
require __DIR__ . '/vendor/autoload.php';
/**
* chat.php
* Send any incoming messages to all connected clients (except sender)
* Send any incoming messages to all connected clients
*/
class MyChat implements MessageComponentInterface
{
@@ -26,11 +25,7 @@ class MyChat implements MessageComponentInterface
public function onMessage(ConnectionInterface $from, $msg)
{
foreach ($this->clients as $client) {
if ($from != $client) {
$client->send($msg);
}
}
$from->send($msg);
}
public function onClose(ConnectionInterface $conn)
@@ -44,8 +39,7 @@ class MyChat implements MessageComponentInterface
}
}
// Run the server application through the WebSocket protocol on port 8080
$app = new Ratchet\App('localhost', 8080);
$app->route('/chat', new MyChat(), array('*'));
$app->route('/echo', new Ratchet\Server\EchoServer(), array('*'));
// Run the server application through the WebSocket protocol on port 4430
$app = new Ratchet\App('crawler.yt.lemnoslife.com', 4430);
$app->route('/websocket', new MyChat(), array('*'));
$app->run();