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);
        }
    }