Пример #1
0
        /// <summary>
        /// 删除监视 WEB 视图服务
        /// </summary>
        /// <param name="server"></param>
        internal static void Remove(ViewServer server)
        {
            HashString         path = server.WorkPath;
            VersionFileWatcher watcher, removeWatcher = null;

            Monitor.Enter(watcherLock);
            try
            {
                if (watchers.TryGetValue(path, out watcher) && watcher.remove(server))
                {
                    watchers.Remove(path);
                    removeWatcher = watcher;
                }
            }
            finally { Monitor.Exit(watcherLock); }
            if (removeWatcher != null)
            {
                removeWatcher.Dispose();
            }
        }
Пример #2
0
 protected new unsafe bool dispose()
 {
     if (base.dispose())
     {
         if (rewritePaths != null)
         {
             rewritePaths.Dispose();
         }
         viewSearcher.State = callSearcher.State = rewriteSearcher.State = webSocketSearcher.State = null;
         Unmanaged.Free(ref viewIndexs);
         Unmanaged.Free(ref callIndexs);
         Unmanaged.Free(ref rewriteIndexs);
         Unmanaged.Free(ref webSocketIndexs);
         if (WebConfig.IsHtmlLinkVersion)
         {
             VersionFileWatcher.Remove(this);
         }
         return(true);
     }
     return(false);
 }
Пример #3
0
        /// <summary>
        /// 启动HTTP服务
        /// </summary>
        /// <param name="registerServer">HTTP 注册管理服务</param>
        /// <param name="domains">域名信息集合</param>
        /// <param name="onStop">停止服务处理</param>
        /// <returns>是否启动成功</returns>
        public override bool Start(HttpRegister.Server registerServer, HttpRegister.Domain[] domains, Action onStop)
        {
            KeyValue <string[], string[]> rewrites = this.rewrites;

            rewritePaths      = new StateSearcher.AsciiSearcher <byte[]>(rewrites.Key, rewrites.Value.getArray(value => value.getBytes()), false);
            viewIndexs        = StateSearcher.AsciiBuilder.Create(views, false);
            viewSearcher      = new StateSearcher.AsciiSearcher(ref viewIndexs);
            callIndexs        = StateSearcher.AsciiBuilder.Create(calls, false);
            callSearcher      = new StateSearcher.AsciiSearcher(ref callIndexs);
            rewriteIndexs     = StateSearcher.AsciiBuilder.Create(viewRewrites, false);
            rewriteSearcher   = new StateSearcher.AsciiSearcher(ref rewriteIndexs);
            webSocketIndexs   = StateSearcher.AsciiBuilder.Create(webSockets, false);
            webSocketSearcher = new StateSearcher.AsciiSearcher(ref webSocketIndexs);
            if (base.Start(registerServer, domains, onStop))
            {
                if (WebConfig.IsHtmlLinkVersion)
                {
                    VersionFileWatcher.Add(this);
                }
                return(true);
            }
            return(false);
        }