public function onClientMessage(array $message)
    {
        try {
            $clientAddress = $message[0];
            $data = json_decode($message[2], true);
            if (empty($clientAddress) || empty($data) || !isset($data['action'])) {
                throw new ServerException('Received malformed client message.');
            }
            switch ($data['action']) {
                case 'command':
                    $this->handleCommand($clientAddress, $data['command']['name']);
                    break;
                case 'job':
                    $this->handleJobRequest($clientAddress, $data['job']['name'], $data['job']['workload'], false);
                    break;
                case 'background_job':
                    $this->handleJobRequest($clientAddress, $data['job']['name'], $data['job']['workload'], true);
                    break;
                default:
                    $this->clientSocket->send('error: unknown action');
                    throw new ServerException('Received request for invalid action.');
            }
        } catch (ServerException $e) {
            $errorMsgPattern = 'Client message error: %s (%s:%d)';
            $this->logger->error(sprintf($errorMsgPattern, $e->getMessage(), $e->getFile(), $e->getLine()));
        }
    }