示例#1
0
 /// <summary>
 /// 触发定时任务
 /// </summary>
 internal override void OnTimer()
 {
     for (AutoCSer.Net.HttpDomainServer.Session session = AutoCSer.Net.HttpDomainServer.Session.SessionEnd; session != null; session = session.DoubleLinkPrevious)
     {
         session.OnTimer();
     }
     for (AutoCSer.IO.CreateFlieTimeoutWatcher watcher = AutoCSer.IO.CreateFlieTimeoutWatcher.Watchers.End; watcher != null; watcher = watcher.DoubleLinkPrevious)
     {
         watcher.OnTimer();
     }
 }
示例#2
0
 /// <summary>
 /// 设置TCP服务端
 /// </summary>
 /// <param name="tcpServer">TCP服务端</param>
 public override void SetTcpServer(AutoCSer.Net.TcpInternalServer.Server tcpServer)
 {
     base.SetTcpServer(tcpServer);
     cacheFileName = AutoCSer.Config.Pub.Default.CachePath + ServerName + (ServerName == tcpServer.Attribute.ServerName ? null : ("_" + tcpServer.Attribute.ServerName)) + ".cache";
     FileWatcher   = new AutoCSer.IO.CreateFlieTimeoutWatcher(ProcessCopyer.Config.CheckTimeoutSeconds, this, AutoCSer.IO.CreateFlieTimeoutType.HttpServerRegister, tcpServer.Log);
     if (!AutoCSer.Config.Pub.Default.IsService && ProcessCopyer.Config.WatcherPath != null)
     {
         try
         {
             FileWatcher.Add(ProcessCopyer.Config.WatcherPath);
         }
         catch (Exception error)
         {
             tcpServer.Log.Add(AutoCSer.Log.LogType.Error, error, ProcessCopyer.Config.WatcherPath);
         }
     }
     try
     {
         if (System.IO.File.Exists(cacheFileName))
         {
             Cache[] cache = AutoCSer.BinarySerialize.DeSerializer.DeSerialize <Cache[]>(System.IO.File.ReadAllBytes(cacheFileName));
             isLoadCache = true;
             if (OnLoadCacheDomain != null)
             {
                 OnLoadCacheDomain();
             }
             for (int index = cache.Length; index != 0;)
             {
                 try
                 {
                     start(ref cache[--index]);
                 }
                 catch (Exception error)
                 {
                     tcpServer.Log.Add(AutoCSer.Log.LogType.Error, error);
                 }
             }
         }
     }
     catch (Exception error)
     {
         tcpServer.Log.Add(AutoCSer.Log.LogType.Error, error);
     }
     if (isLoadCache)
     {
         isLoadCache = false;
     }
     else if (OnLoadCacheDomain != null)
     {
         OnLoadCacheDomain();
     }
 }
示例#3
0
 private static void onTime(Date.NowTime.OnTimeFlag flag)
 {
     if ((flag & Date.NowTime.OnTimeFlag.HttpSession) != 0)
     {
         for (AutoCSer.Net.HttpDomainServer.Session session = AutoCSer.Net.HttpDomainServer.Session.SessionEnd; session != null; session = session.DoubleLinkPrevious)
         {
             session.OnTimer();
         }
     }
     if ((flag & Date.NowTime.OnTimeFlag.CreateFlieTimeoutWatcher) != 0)
     {
         for (AutoCSer.IO.CreateFlieTimeoutWatcher watcher = AutoCSer.IO.CreateFlieTimeoutWatcher.Watchers.End; watcher != null; watcher = watcher.DoubleLinkPrevious)
         {
             watcher.OnTimer();
         }
     }
 }
示例#4
0
 private void stopListen(bool isStop)
 {
     if (isStop)
     {
         if (FileWatcher != null)
         {
             FileWatcher.Dispose();
             FileWatcher = null;
         }
         Monitor.Enter(hostLock);
         try
         {
             foreach (Http.Server server in hosts.Values)
             {
                 server.StopListen();
             }
         }
         catch (Exception error)
         {
             server.AddLog(error);
         }
         finally { Monitor.Exit(hostLock); }
         Monitor.Enter(domainLock);
         try
         {
             domains.StopListen();
         }
         catch (Exception error)
         {
             server.AddLog(error);
         }
         finally { Monitor.Exit(domainLock); }
         if (OnStopListen != null)
         {
             OnStopListen();
         }
     }
 }