private void Publish(SSEvent eve) { if (SSEPublished != null) { SSEPublished(eve); } }
void ProcessLines() { var lines = SSECore.Queue; SSEvent lastEvent = null; int lastEventIdx = -1; for (int i = 0; i < lines.Count; i++) { var line = lines[i]; if (String.IsNullOrWhiteSpace(line)) { continue; } line = line.Trim(); if (line.StartsWith("event:")) { lastEvent = new SSEvent() { Name = line.Replace("event:", String.Empty) }; } else if (line.StartsWith("data:")) { if (lastEvent == null) { continue; } lastEvent.SetData(line.Replace("data:", String.Empty)); lastEventIdx = i; } } Publish(lastEvent); //trim previously processed events if (lastEventIdx >= 0) { lines.RemoveRange(0, lastEventIdx); } }
void ProcessLines() { var lines = SSECore.Queue; SSEvent lastEvent = null; int lastEventIdx = -1; for(int i=0;i<lines.Count;i++) { var line = lines[i]; if (String.IsNullOrWhiteSpace(line)) { continue; } line = line.Trim(); if (line.StartsWith("event:")) { lastEvent = new SSEvent() { Name = line.Replace("event:", String.Empty) }; } else if (line.StartsWith("data:")) { if (lastEvent == null) { continue; } lastEvent.SetData(line.Replace("data:", String.Empty)); lastEventIdx = i; } } Publish (lastEvent); //trim previously processed events if (lastEventIdx >= 0) { lines.RemoveRange(0, lastEventIdx); } }
private void Publish(SSEvent eve) { if (SSEPublished != null) SSEPublished (eve); }