AbduallahMohsen

Untitled

Apr 11th, 2020
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.68 KB | None | 0 0
  1.                 case "et":
  2.                     {
  3.                         if (data.Length == 1)
  4.                         {
  5.                             MyConsole.WriteLine("\t\tReceivePool-> et rp 'Priority' 'ThreadCount'.\n\t\tSendPool-> et sp 'Priority' 'ThreadCount'.\n\t\tConnectionReceive-> et cr 'Priority'.\n\t\tConnectionSend-> et cs 'Priority'.");
  6.                             return;
  7.                         }
  8.                         //Lowest = 0, BelowNormal = 1, Normal = 2, AboveNormal = 3, Highest = 4
  9.                         int ThreadCount;
  10.                         System.Threading.ThreadPriority Priority;
  11.  
  12.                         if (!System.Threading.ThreadPriority.TryParse(data[2], out Priority))
  13.                         {
  14.                             MyConsole.WriteLine("Please Set Thread Priority.");
  15.                             return;
  16.                         }
  17.  
  18.                         switch (data[1].ToLower())
  19.                         {
  20.                             case "rp"://ReceivePool
  21.                                 {
  22.                                     if (!int.TryParse(data[2], out ThreadCount))
  23.                                     {
  24.                                         MyConsole.WriteLine("Please Set Thread Count.");
  25.                                         return;
  26.                                     }
  27.  
  28.                                     foreach (var user in Kernel.GamePool.Values)
  29.                                         user.Socket.TimerSubscriptions[0].Dispose();
  30.  
  31.                                     World.ReceivePool.cleanUp(true);
  32.                                     World.ReceivePool = new StaticPool(ThreadCount, Priority);
  33.                                     World.ReceivePool.Run();
  34.  
  35.                                     foreach (var user in Kernel.GamePool.Values)
  36.                                         user.Socket.TimerSubscriptions[0] = World.Subscribe<ClientWrapper>(Program.World.ConnectionReceive, user.Socket, World.ReceivePool);
  37.                                     break;
  38.                                    
  39.                                 }
  40.                             case "sp"://SendPool
  41.                                 {
  42.                                     if (!int.TryParse(data[2], out ThreadCount))
  43.                                     {
  44.                                         MyConsole.WriteLine("Please Set Thread Count.");
  45.                                         return;
  46.                                     }
  47.                                     foreach (var user in Kernel.GamePool.Values)
  48.                                         user.Socket.TimerSubscriptions[1].Dispose();
  49.  
  50.                                     World.SendPool.cleanUp(true);
  51.                                     World.SendPool = new StaticPool(ThreadCount, Priority);
  52.                                     World.SendPool.Run();
  53.  
  54.                                     foreach (var user in Kernel.GamePool.Values)
  55.                                         user.Socket.TimerSubscriptions[1] = World.Subscribe<ClientWrapper>(Program.World.ConnectionSend, user.Socket, World.SendPool);
  56.                                     break;
  57.                                 }
  58.                             case "cr"://ConnectionReceive
  59.                                 {
  60.                                     foreach (var user in Kernel.GamePool.Values)
  61.                                         user.Socket.TimerSubscriptions[0].Dispose();
  62.  
  63.                                     World.ConnectionReceive = new Generic.TimerRule<ClientWrapper>(World.connectionReceive, 1, Priority);
  64.  
  65.                                     foreach (var user in Kernel.GamePool.Values)
  66.                                         user.Socket.TimerSubscriptions[0] = World.Subscribe<ClientWrapper>(Program.World.ConnectionReceive, user.Socket, World.ReceivePool);
  67.                                     break;
  68.                                 }
  69.                             case "cs"://ConnectionSend
  70.                                 {
  71.                                     foreach (var user in Kernel.GamePool.Values)
  72.                                         user.Socket.TimerSubscriptions[1].Dispose();
  73.  
  74.                                     World.ConnectionSend = new Generic.TimerRule<ClientWrapper>(World.connectionSend, 1, Priority);
  75.  
  76.                                     foreach (var user in Kernel.GamePool.Values)
  77.                                         user.Socket.TimerSubscriptions[1] = World.Subscribe<ClientWrapper>(Program.World.ConnectionSend, user.Socket, World.SendPool);
  78.                                     break;
  79.                                 }
  80.                         }
  81.                         break;
  82.                     }
Advertisement
Add Comment
Please, Sign In to add comment