mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 15:14:52 +09:00
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:
1 parent
b84c5b4293
commit
dea3a30cae
3 files changed
+65
-10
No files matched your search
@@ -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" },
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user