mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-16 16:25:54 +01:00
39 lines
790 B
ObjectPascal
39 lines
790 B
ObjectPascal
|
unit SSEControllerU;
|
||
|
|
||
|
|
||
|
interface
|
||
|
|
||
|
uses
|
||
|
MVCFramework, MVCFramework.Commons, MVCFramework.SSEController;
|
||
|
|
||
|
type
|
||
|
[MVCPath('/stocks')]
|
||
|
TMySSEController = class(TMVCSSEController)
|
||
|
protected
|
||
|
function GetServerSentEvents(const LastEventID: String): TMVCSSEMessages; override;
|
||
|
end;
|
||
|
|
||
|
implementation
|
||
|
|
||
|
uses
|
||
|
MVCFramework.Logger, System.SysUtils, StorageU, System.DateUtils;
|
||
|
|
||
|
{ TMySSEController }
|
||
|
|
||
|
function TMySSEController.GetServerSentEvents(const LastEventID: String): TMVCSSEMessages;
|
||
|
var
|
||
|
lCurrentEventID: Integer;
|
||
|
lSSEMessage: TSSEMessage;
|
||
|
begin
|
||
|
Sleep(1000);
|
||
|
lSSEMessage.Event := 'stockupdate';
|
||
|
lSSEMessage.Data := GetNextDataToSend(StrToIntDef(LastEventID, 0), lCurrentEventID);
|
||
|
lSSEMessage.Id := lCurrentEventID.ToString;
|
||
|
Result := [
|
||
|
lSSEMessage
|
||
|
];
|
||
|
end;
|
||
|
|
||
|
end.
|
||
|
|