Sample project to illustrate a plugin discovery with a custom WebSocket server.
⚡ Use the Piral Feed Service for plugin discovery - creating an extensible reactive WebSocket server.
Feel free to play around with the code using StackBlitz.
Let's say you start a quick session:
const ws = new WebSocket('ws://localhost:3000');
ws.onmessage = (e) => {
console.log(JSON.parse(e.data));
};
ws.send(JSON.stringify({ type: 'foo' })); // response will be from app1: "Hello from app1 v2: foo"
ws.send(JSON.stringify({ type: 'compute', a: 5, b: 8, correlationId: 'abcdef' })); ; // response will be from app2: -39 (incl. the correlationId)
ws.send(JSON.stringify({ type: 'list-documents' })); // also check out create-document and delete-document; they all come from app3
Only the type
and correlationId
fields are given. All others are dynamically passed to the command handlers.
Piral and this sample code is released using the MIT license. For more information see the license file.