1. Go to this page and download the library: Download ekstazi/reamp 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/ */
ekstazi / reamp example snippets
use Reamp\MessageComponentInterface;
use Reamp\ConnectionInterface;
// Make sure composer dependencies have been installed
face {
protected $clients;
public function __construct() {
$this->clients = new \SplObjectStorage;
}
public function onOpen(ConnectionInterface $conn) {
$this->clients->attach($conn);
}
public function onMessage(ConnectionInterface $from, $msg) {
foreach ($this->clients as $client) {
if ($from != $client) {
$client->send($msg);
}
}
}
public function onClose(ConnectionInterface $conn) {
$this->clients->detach($conn);
}
public function onError(ConnectionInterface $conn, \Throwable $e) {
$conn->close();
}
}
// Run the server application through the WebSocket protocol on port 8080
$app = new Reamp\App('localhost', 8080);
$app->route('/chat', new MyChat);
$app->route('/echo', new Reamp\Server\EchoServer, array('*'));
$app->run();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.