Skip to content

Commit 65f8df3

Browse files
committed
docs: fix client example
1 parent 34ebcae commit 65f8df3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,21 @@ server.on('client', async (client) => {
7777
console.log(`Server got ${method} from ${client.identity}:`, params);
7878
throw createRPCError("NotImplemented");
7979
});
80+
8081
client.handle('BootNotification', ({params}) => {
8182
console.log(`Server got BootNotification from ${client.identity}:`, params);
82-
return {status: "Accepted"};
83+
return {status: "Accepted", interval: 300, currentTime: new Date().toISOString()};
8384
});
85+
8486
client.handle('Heartbeat', ({params}) => {
8587
console.log(`Server got Heartbeat from ${client.identity}:`, params);
8688
return {currentTime: new Date().toISOString()};
8789
});
90+
91+
client.handle('StatusNotification', ({params}) => {
92+
console.log(`Server got StatusNotification from ${client.identity}:`, params);
93+
return {};
94+
});
8895
});
8996

9097
await server.listen(3000);
@@ -637,6 +644,8 @@ As a callee, `strictMode` has the following effects:
637644
* If an inbound call's params fail validation, the call will not be passed to a handler. Instead, an error response will be automatically issued to the caller with an appropriate RPC error. A [`'strictValidationFailure'`](#event-strictvalidationfailure) event will be emitted with an [`RPCError`](#rpcerror).
638645
* If your response to a call fails validation, the response will be discarded and an `"InternalError"` RPC error will be sent instead. A [`'strictValidationFailure'`](#event-strictvalidationfailure) event will be emitted with an [`RPCError`](#rpcerror).
639646

647+
**Important:** If you are using `strictMode`, you are strongly encouraged to listen for [`'strictValidationFailure'`](#event-strictvalidationfailure) events, otherwise you may not know if your responses or inbound calls are being dropped for failing validation.
648+
640649
### Supported validation schemas
641650

642651
This module natively supports the following validation schemas:

0 commit comments

Comments
 (0)