diff --git a/shared/apc/index.mjs b/shared/apc/index.mjs new file mode 100644 index 0000000..4fbdd1d --- /dev/null +++ b/shared/apc/index.mjs @@ -0,0 +1,15 @@ +import { Buffer } from 'buffer'; + +export class AsyncProcedureCallEndpoint { + /** + * Constructs an AsyncProcedureCallEndpoint object. + * @param {any} input - stream of data sent by remote. + * @param {any} output - stream of data to send to remote. + */ + constructor(input, output) { + this.buf = Buffer(); + input.ondata = () => { + + }; + } +}; diff --git a/shared/apc/package.json b/shared/apc/package.json new file mode 100644 index 0000000..1ab705e --- /dev/null +++ b/shared/apc/package.json @@ -0,0 +1,11 @@ +{ + "name": "@og/async-procedure-call", + "type": "module", + "main": "index.mjs", + "dependencies": { + "buffer": "^6.0.3", + "@og/error-utils": "file:../error-utils", + "@og/uuid": "file:../uuid", + "@og/binary-struct": "file:../bstruct" + } +} \ No newline at end of file diff --git a/shared/error-utils/index.mjs b/shared/error-utils/index.mjs index 3357e13..ddc25a3 100644 --- a/shared/error-utils/index.mjs +++ b/shared/error-utils/index.mjs @@ -9,3 +9,15 @@ export class VirtualMethodNotImplementedError extends Error { super('virtual method not implemented.'); } }; + +/** + * Represents an error that is thrown when called a function with invalid arguments. + * @class + * @extends {Error} + */ +export class InvalidArgumentError extends Error { + /** @constructor */ + constructor(name, reason) { + super(`argument ${name} is invalid: ${reason}.`); + } +};