Askedio\LaravelRatchet\RatchetServer::onMessage PHP Method

onMessage() public method

Perform action on message.
public onMessage ( Ratchet\ConnectionInterface $conn, [type] $input ) : [type]
$conn Ratchet\ConnectionInterface [description]
$input [type]
return [type]
    public function onMessage(ConnectionInterface $conn, $input)
    {
        $this->console->comment(sprintf('Message from %d: %s', $conn->resourceId, $input));
        if ($this->isThrottled($conn, 'onMessage')) {
            $this->console->info(sprintf('Message throttled: %d', $conn->resourceId));
            $this->send($conn, trans('ratchet::messages.toManyMessages'));
            $this->throttled = true;
            if (config('ratchet.abortOnMessageThrottle')) {
                $this->abort($conn);
            }
        }
    }

Usage Example

 public function onMessage(ConnectionInterface $conn, $input)
 {
     parent::onMessage($conn, $input);
     if (!$this->throttled) {
         $this->send($conn, sprintf('- %s', $input));
     }
 }