UNPKG

ws-rmi

Version:

A Remote Method Invocation implementation written in JavaScript utilising the WebSocket protocol

19 lines (18 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateRMIRequest = exports.createRMIRequest = void 0; const RMIMessage_1 = require("./RMIMessage"); const JSONValidation_1 = require("../JSONValidation"); /** * Creates an object adhering to the RMI Request schema. * * @param id The ID to uniquely identify the RMI Result that the remote sends back. * @param target The target function to be invoked. * @param args The function arguments to be invoked in the remote. */ const createRMIRequest = (id, target, args) => (0, RMIMessage_1.createRMIMessage)(id, "REQUEST", { target, args }); exports.createRMIRequest = createRMIRequest; /** * Validates that the given message is an RMI Request. */ exports.validateRMIRequest = (0, RMIMessage_1.createRMIMessageValidator)((data) => (0, JSONValidation_1.isObject)(data) && (0, JSONValidation_1.hasPropertyOfType)(data, "target", JSONValidation_1.isString) && (0, JSONValidation_1.hasPropertyOfType)(data, "args", JSONValidation_1.isArray));