Beispiel #1
0
    def notify(self, method: str, params=None):
        """Sends a JSON RPC notification to the client."""
        logger.debug('Sending notification: "%s" %s', method, params)

        request = JsonRPCNotification(jsonrpc=JsonRPCProtocol.VERSION,
                                      method=method,
                                      params=params)

        self._send_data(request)
Beispiel #2
0
def deserialize_message(data, get_params_type=get_method_params_type):
    """Function used to deserialize data received from client."""
    if 'jsonrpc' in data:
        try:
            deserialize_params(data, get_params_type)
        except ValueError:
            raise JsonRpcInvalidParams()

        if 'id' in data:
            if 'method' in data:
                return JsonRPCRequestMessage(**data)
            else:
                return JsonRPCResponseMessage(**data)
        else:
            return JsonRPCNotification(**data)

    return data