So far have this though as mentioned it it's not working - ProcessRequest is reached and run ok but client is not showing any data and similarly browser debug tools do not show any data in the EventStream
I'll answer my own question - after some further testing i realized the chunks were not being sent since default minimum chunk size is 16K.
For now i just set it to 5 bytes and tings started working
C.Response.MinChunkSize := 5;
I think the only follow-up question i have
Is there a built-in mechanism for THttpServerModule ProcessRequest to know it should be stopping - I'm basically doing a busy wait loop so i'd need to add some a check for some "server shutting down" type of flag/event. Client side is OK as that would be captured
Is there a better way you can suggest to implement server side events ?
One thing you could do is check the TSparkleHttpSysDispatcher.IsRunning property. When the server is requested to stop, it will wait for threads to finish, until a timeout happens. Then, IsRunning is set to false.
I don't think there would be a better way to implement this, I guess.
I have a question about server sent event.Client side I connect to server and close but I don't take data value.Here my javascript code what is the wrong please help me.
unction start() {
if (!window.EventSource) {
// IE or an old browser
alert("The browser doesn't support EventSource.");
return;
}
Sorry, but I don't have experience with server-side events, never used it either in JavaScript or Sparkle. Maybe @Wilson_Jason can provide some info if he was successful in implementing this.
I recognize a error ;
ERROR
Uncaught TypeError: Cannot read property 'length' of undefined | TypeError: Cannot read property 'length' of undefined at Object.ProcessAccelerator