Example #1
0
 /// <summary>
 /// Đăng ký một route mới, mỗi route ánh xạ một chuỗi truy vấn với một phương thức
 /// </summary>
 /// <param name="route"></param>
 /// <param name="action"></param>
 /// <param name="help"></param>
 public void Register(string route, ControllerAction action, string help = "")
 {
     // nếu _routingTable đã chứa route này thì bỏ qua
     if (!_routingTable.ContainsKey(route))
     {
         _routingTable[route] = action;
         _helpTable[route]    = help;
     }
 }
 public void UpdateRouteTable(Router sender, RoutingTable recievedTable)
 {
     Links[sender] = routerTimeout;
     foreach (Router rTo in recievedTable.Keys.Where(x => x != this))
     {
         if (!table.ContainsKey(rTo))
         {
             table.Add(rTo, new Dictionary <Router, int>());
         }
         if (!table[rTo].ContainsKey(sender))
         {
             table[rTo].Add(sender, recievedTable[rTo].First().Value + 1);
         }
         table[rTo][sender] = Math.Min(16, recievedTable[rTo].Values.Min() + 1);
     }
 }