function sendMessageToWorker(\CharlotteDunois\Phoebe\Worker $worker, \CharlotteDunois\Phoebe\Message $message) {
        if(!$worker->isRunning()) {
            throw new \RuntimeException('Tried to send a message to a non-running worker');
        }
        
        if($this->messenger->usesSockets()) {
            $socket = $this->messenger->getWorkerSocket($worker);
            if($socket === null) {
                throw new \RuntimeException('Tried to send a message to a worker with a closed socket (shutting down)');
            }
            
            $data = \CharlotteDunois\Phoebe\Socket::encodeMessage($message);
            $socket->write($data);
        } else {
            $worker->sendMessageToWorker($message);
        }
    }
function sendMessageToWorker(\CharlotteDunois\Phoebe\Worker $worker, \CharlotteDunois\Phoebe\Message $message) {
        if(!$worker->isRunning()) {
            throw new \RuntimeException('Tried to send a message to a non-running worker');
        }
        
        if($this->messenger->usesSockets()) {
            $socket = $this->messenger->getWorkerSocket($worker);
            if($socket === null) {
                throw new \RuntimeException('Tried to send a message to a worker with a closed socket (shutting down)');
            }
            
            $data = \CharlotteDunois\Phoebe\Socket::encodeMessage($message);
            $socket->write($data);
        } else {
            $worker->sendMessageToWorker($message);
        }
    }
function sendMessageToWorker ( \ CharlotteDunois \ Phoebe \ Worker $ worker , \ CharlotteDunois \ Phoebe \ Message $ message ) { if ( ! $ worker -> isRunning ( ) ) { throw new \ RuntimeException ( 'Tried to send a message to a non-running worker' ) ; } if ( $ this -> messenger -> usesSockets ( ) ) { $ socket = $ this -> messenger -> getWorkerSocket ( $ worker ) ; if ( $ socket === null ) { throw new \ RuntimeException ( 'Tried to send a message to a worker with a closed socket (shutting down)' ) ; } $ data = \ CharlotteDunois \ Phoebe \ Socket :: encodeMessage ( $ message ) ; $ socket -> write ( $ data ) ; } else { $ worker -> sendMessageToWorker ( $ message ) ; } }
Sends a message to the worker thread.
@param \CharlotteDunois\Phoebe\Worker   $worker
@param \CharlotteDunois\Phoebe\Message  $message
@return void
@throws \RuntimeException
Sends a message to the worker thread .