SSE support
Issue
Old style REST API devices have GET/PUT commands whereby the client can read/write data to the server (i.e. a client driven, polling mechanism). But nowadays many REST API devices also support Server Sent Eventing (SSE) whereby the server can inform the client directly if anything changes. (i.e. a server event driven mechanism).
Example
This is often the case in home automation devices (e.g. Philips Hue) where the server device can (say) notify the client that a light was turned on or a temperature has changed.
Analog
Some implementers use SSE to send event notifications. But some use WebSockets instead. The implementation is slightly different, but the purpose is the same. => So see #83
Proposed Solution
Mockoon should add the following features..
- Ability for a client to open an SSE connection to Mockoon server.
- (Ditto ability for the client to open a WebSocket connection to Mockoon server).
- Ability to define response payloads (usually JSON) that Mockoon server can send over the SSE (resp. WebSocket) connection.
- Above mentioned responses are sent with a delay of (0 .. n seconds) after the connection is opened (or even a random delay to simulate real life events).
- Above mentioned responses would allow variable contents, as with existing Mockoon responses, to simulate real life.
Signed-off-by: Andrew Fiddian-Green [email protected]
Source: mockoon/mockoon