public function onWorkerMessage(MessageInterface $msg)
    {
        if ($msg instanceof Protocol\ActionListRequest) {
            $this->getLogger()->debug('[SERVICE] Returning list of actions.');
            $this->stream->send(new Protocol\ActionListResponse($this->getActionList()));

            return;
        }

        if ($msg instanceof Protocol\ExecuteJobRequest) {
            $requestId = $msg->getRequestId();
            $action = $msg->getAction();

            $this->getLogger()->debug('[SERVICE] Job for action: '.$action.' with id: '.$requestId);

            $params = array();
            $serialized = $msg->getParams();
            foreach ($serialized as $param) {
                $params[] = $this->getSerializer()->unserialize($param);
            }

            if (!isset($this->actions[$action])) {
                $this->getLogger()->notice('[SERVICE] Action '.$action.' not found.');
                $this->stream->send(new Protocol\ActionNotFound($requestId, $action));

                return;
            }

            $return = $this->execute($action, $params);
            $sendReturn = $this->getSerializer()->serialize($return);

            $this->stream->send(new Protocol\ExecuteJobResponse($requestId, $sendReturn));

            return;
        }

        throw new RuntimeException('Invalid request.');
    }