[Lazarus] fpWeb and server-sent events
silvioprog at gmail.com
Wed Jun 3 18:53:40 CEST 2020
I hope you are fine in the current world situation.
Some answers below to your questions 1 and 2.
On Wed, Jun 3, 2020 at 10:30 AM Luca Olivetti via lazarus <
lazarus at lists.lazarus-ide.org> wrote:
> I need to embed a simple web server in my application that
> 1) should server a couple of static files
> 2) send server-sent events
1) So, you can use any Pascal structure to serve files, even in a single
routine. BTW, if you want to resolve media types, you can use
fpmimetypes or BrookMediaTypes
2) As Michael explained, unfortunately, it is not supported in FCL-Web
(yet) . However, if you want a SSE structure out-of-the-box, you can
provide it using the Brook streaming, e.g.:
Minimal console example:
Minimal LCL example:
Both examples above declare a small HTML client showing how to consume it
via event source (EventSource). Optionally, you can use some async
structure (e.g.: TSpinWait.SpinUntil) to create a small polling to push/pop
the messages provided to the clients in a single long lived event.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the lazarus