Skip to content

Commit

Permalink
Update MVCFramework.SSEClient.pas (#782)
Browse files Browse the repository at this point in the history
Since the format of SSE contains spaces between command and value, we have to trim the value part.
sample:
event: userconnect
data: {"username": "bobby", "time": "02:33:48"}
  • Loading branch information
radexpol authored Sep 25, 2024
1 parent edbf90e commit d3525de
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sources/MVCFramework.SSEClient.pas
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ procedure TMVCSSEClient.ExtractMessage(const ASSEMessage: string);
SSEMessage.Text := ASSEMessage;

if SSEMessage.IndexOfName('id')>-1 then
fLastEventId := SSEMessage.Values['id'].ToInteger;
fLastEventId := SSEMessage.Values['id'].Trim.ToInteger;
if SSEMessage.IndexOfName('event')>-1 then
event := SSEMessage.Values['event'];
event := SSEMessage.Values['event'].Trim;
if SSEMessage.IndexOfName('data')>-1 then
data := SSEMessage.Values['data'];
data := SSEMessage.Values['data'].Trim;
if SSEMessage.IndexOfName('retry')>-1 then
fReconnectTimeout := StrToIntDef(SSEMessage.Values['retry'], DefaultReconnectTimeout);
fReconnectTimeout := StrToIntDef(SSEMessage.Values['retry'].Trim, DefaultReconnectTimeout);

fOnSSEEvent(Self, fLastEventId, event, data);
finally
Expand Down

0 comments on commit d3525de

Please sign in to comment.