コード例 #1
0
 private static async Task MessageCallback(Message m)
 {
     for (var i = Subscribers.Count - 1; i >= 0; i--)
     {
         try
         {
             await Subscribers[i].WriteLineAsync("data:" + JsonConvert.SerializeObject(m) + "\n");
             await Subscribers[i].WriteLineAsync("");
             await Subscribers[i].FlushAsync();
         }
         catch (Exception)
         {
             lock (locker)
             {
                 Subscribers.RemoveAt(i);
             }
         }
     }
 }
コード例 #2
0
 public async Task Post(Message m)
 {
     m.DateTime = DateTime.Now;
     await MessageCallback(m);
 }