private void ProcessResponseContent(string content) { if (content == null) { // StreamReader may emit a null if the stream has been closed; there's nothing to // be done at this level in that case return; } if (string.IsNullOrEmpty(content.Trim())) { DispatchEvent(); } else if (EventParser.IsComment(content)) { OnCommentReceived(new CommentReceivedEventArgs(content)); } else if (EventParser.ContainsField(content)) { var field = EventParser.GetFieldFromLine(content); ProcessField(field.Key, field.Value); } else { ProcessField(content.Trim(), string.Empty); } }
private void ProcessField(string field, string value) { if (EventParser.IsDataFieldName(field)) { _eventBuffer.Add(value); _eventBuffer.Add("\n"); } else if (EventParser.IsIdFieldName(field)) { _lastEventId = value; } else if (EventParser.IsEventFieldName(field)) { _eventName = value; } else if (EventParser.IsRetryFieldName(field) && EventParser.IsStringNumeric(value)) { long retry; if (long.TryParse(value, out retry)) { _retryDelay = TimeSpan.FromMilliseconds(retry); } } }
private void ProcessResponseLineUtf8(Utf8ByteSpan content) { if (content.Length == 0) { DispatchEvent(); } else { HandleParsedLine(EventParser.ParseLineUtf8Bytes(content)); } }
private void ProcessResponseLineString(string content) { if (content == null) { // StreamReader may emit a null if the stream has been closed; there's nothing to // be done at this level in that case return; } if (content.Length == 0) { DispatchEvent(); } else { HandleParsedLine(EventParser.ParseLineString(content)); } }
private void ProcessResponseContent(string content) { if (string.IsNullOrEmpty(content.Trim())) { DispatchEvent(); } else if (EventParser.IsComment(content)) { OnCommentReceived(new CommentReceivedEventArgs(content)); } else if (EventParser.ContainsField(content)) { var field = EventParser.GetFieldFromLine(content); ProcessField(field.Key, field.Value); } else { ProcessField(content.Trim(), string.Empty); } }