PHP code example of ad3n / ratchet-bundle
1. Go to this page and download the library: Download ad3n/ratchet-bundle 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/ */
ad3n / ratchet-bundle example snippets
namespace YourBundle\Message\Processor;
use Ihsan\RatchetBundle\Message\Message;
use Ihsan\RatchetBundle\Processor\MessageProcessorInterface;
use Ratchet\ConnectionInterface;
/**
* @author Muhamad Surya Iksanudin <[email protected]>
*/
class MyOwnMessageProcessor implements MessageProcessorInterface
{
/**
* @param ConnectionInterface $connection
* @param Message $message
*
* @return Message
*/
public function process(ConnectionInterface $connection, Message $message): Message
{
//$message is message send by the client
//Your Own Logic
return $message;//return original message or
//return new Message(json_encode(['message' => 'Hello', 'more_data_to_expose' => $data]));
}
}
bin/console ihsan:server:start