Exemplo n.º 1
0
 private static void Publish(SSEvent eve)
 {
     if (SSEPublished != null)
     {
         SSEPublished(eve);
     }
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 4
0
 private static void Publish(SSEvent eve)
 {
     if (SSEPublished != null)
         SSEPublished (eve);
 }