예제 #1
0
 private static void Publish(SSEvent eve)
 {
     if (SSEPublished != null)
     {
         SSEPublished(eve);
     }
 }
예제 #2
0
        static 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
        static 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 static void Publish(SSEvent eve)
 {
     if (SSEPublished != null)
         SSEPublished (eve);
 }