PHP code example of modassir / sse
1. Go to this page and download the library: Download modassir/sse library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
modassir / sse example snippets
use Modassir\SSE\Connection\ConnectionInterface;
use Modassir\SSE\SSEComponentInterface;
use Modassir\SSE\SSE;
n onOpen(ConnectionInterface $conn)
{
//
}
public function onMessage(ConnectionInterface $conn, $message)
{
$conn->export();
}
public function onError(ConnectionInterface $conn, $e)
{
//
}
}
(new SSE(new Chat()))->run();
use Modassir\SSE\Sender\Sender;
r->onSend(function() {
echo 'message sent successfully!';
});
$sender->send($_POST['data']);