Пример #1
0
 private void Publish(SSEvent eve)
 {
     if (SSEPublished != null)
     {
         SSEPublished(eve);
     }
 }
Пример #2
0
        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);
            }
        }
Пример #3
0
		 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); 
			}
		}
Пример #4
0
		private void Publish(SSEvent eve)
		{
			if (SSEPublished != null)
				SSEPublished (eve);
		}