Make a WebSocket example work with crawler.yt.lemnoslife.com
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user