예제 #1
0
    def process_response(self, req: Request, resp: Response):
        if not req:
            return

        if req.method == Commands.ACTIVATE_COMMAND and resp.is_message():
            self._prepare_service()
            if self._handler:
                self._handler.on_service_statistic_received(resp.result)
예제 #2
0
    def process_response(self, req: Request, resp: Response):
        if not req:
            return

        if req.method == Commands.ACTIVATE_COMMAND and resp.is_message():
            if self._handler:
                self._set_runtime_fields(resp.result[ServiceClient.HTTP_HOST],
                                         resp.result[ServiceClient.VODS_HOST],
                                         resp.result[ServiceClient.SUBSCRIBERS_HOST],
                                         resp.result[ServiceClient.BANDWIDTH_HOST], resp.result[ServiceClient.VERSION])
                self._handler.on_service_statistic_received(resp.result)

        if req.method == Commands.PREPARE_SERVICE_COMMAND and resp.is_message():
            for directory in resp.result:
                if Client.VODS_IN_DIRECTORY in directory:
                    self._vods_in = directory[Client.VODS_IN_DIRECTORY]['content']
                    break
예제 #3
0
def generate_json_rpc_response_error(message: str, code: int,
                                     command_id: str) -> Response:
    return Response(command_id, None, {'code': code, 'message': message})
예제 #4
0
def generate_json_rpc_response_message(result, command_id: str) -> Response:
    return Response(command_id, result)