mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 16:55:37 +02:00
Merging this prematurely to make sure the team is on the same boat... like dang! We need to find a better way to do this. Plus it has become too big
19 lines
392 B
C#
19 lines
392 B
C#
using System.Text.Json;
|
|
|
|
public class ServerSentEvent
|
|
{
|
|
public string Type { get; set; }
|
|
public object Data { get; set; }
|
|
|
|
public ServerSentEvent(string type, object data)
|
|
{
|
|
Type = type;
|
|
Data = data;
|
|
}
|
|
|
|
public string Serialize()
|
|
{
|
|
var dataJson = JsonSerializer.Serialize(Data);
|
|
return $"event: {Type}\ndata: {dataJson}\n\n";
|
|
}
|
|
} |