コード例 #1
0
 /// <summary>
 /// 发送
 /// </summary>
 /// <param name="param"></param>
 private void btnSendExecute(object param)
 {
     try
     {
         var list  = appServer.GetAllSessions().ToList();
         int count = int.Parse(textBox.Text);
         if (count > list.Count())
         {
             count = list.Count();
         }
         for (int i = 0; i < count; i++)
         {
             int c = i;
             Task.Factory.StartNew(() =>
             {
                 Thread.Sleep(100);
                 string str = $"{new Random().Next(1, 999)} {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}\r\n";
                 Console.WriteLine($"{list[c].SessionID}-{str}");
                 // list[c].Send(Encoding.Default.GetBytes(str), 0, str.Length);
             });
         }
     }
     catch (Exception ex)
     {
         appServer.Logger.Error(ex);
     }
 }
コード例 #2
0
 public IEnumerable <AppSession> GetAllSessions()
 {
     return(appServer.GetAllSessions());
 }