The IServerEvent.Data
property is defined by the interface to be an object
. Hence this object needs to be serialized prior to broadcasting it down to connected clients. By default the FubuMVC.ServerSentEvents bottle will use the FubuMVC JSON serializer. So an example stream would look like this:
1 2 3 4 |
|
You can easily change the serializer by implementing your own version of IDataFormatter
then in your registry add ReplaceService<IDataFormatter, YOURIMPLEMENTATION>()
This is where appending the event name to the end of the event id comes in handy. You can route all of your events to the default message
handler on the client, deserialize the data, then trigger a non-SSE event with the deserialized data, similar to how everything else is handled in FubuMVC.