Allow optional top level properties in messages

Add optional arguments to Request and Event to control which properties
are required to be present in the payload.  This allows gracefully
extending the protocol, reducing overhead for optional data, and leaving
properties out for additional behaviour.
This commit is contained in:
Hornwitser committed 2021-01-22 12:20:27 +01:00
1 parent b84c5b4293
commit dea3a30cae
3 files changed
+65 -10

No files matched your search

+6
View File
@@ -17,11 +17,15 @@ describe("lib/link/messages", function() {
let testRequest = new libLink.Request({
type: "test",
links: ["source-target"],
requestRequired: ["test"],
requestProperties: {
"test": { type: "string" },
"optional": { type: "number" },
},
responseRequired: ["test"],
responseProperties: {
"test": { type: "string" },
"optional": { type: "number" },
},
});
@@ -127,8 +131,10 @@ describe("lib/link/messages", function() {
let testEvent = new libLink.Event({
type: "test",
links: ["source-target"],
eventRequired: ["test"],
eventProperties: {
"test": { type: "string" },
"optional": { type: "number" },
},
});