コード例 #1
0
ファイル: MarshallerChannel.cs プロジェクト: Azure/RingMaster
        private IWatcher RegisterWrapperWatcher(string path, IWatcher watcher)
        {
            var wrapper = new WrapperWatcher(path, watcher);

            wrapper.Id = this.watchers.CreateNewIdForObject(wrapper);
            return(wrapper);
        }
コード例 #2
0
ファイル: MarshallerChannel.cs プロジェクト: Azure/RingMaster
        /// <summary>
        /// notifies all watchers about the disconnection
        /// </summary>
        public void NotifyAllWatchers()
        {
            lock (this.watchers)
            {
                if (this.isDisposed)
                {
                    return;
                }

                // the channel is gone! notify all pending watchers
                foreach (IWatcher watcher in this.watchers.GetAll())
                {
                    try
                    {
                        string         path           = string.Empty;
                        WrapperWatcher wrapperWatcher = watcher as WrapperWatcher;
                        if (wrapperWatcher != null)
                        {
                            path = wrapperWatcher.Path;
                        }
                        else if (watcher is FakeProxyWatcher)
                        {
                            path = ((FakeProxyWatcher)watcher).Path;
                        }

                        watcher.Process(new WatchedEvent(WatchedEvent.WatchedEventType.WatcherRemoved, WatchedEvent.WatchedEventKeeperState.Disconnected, path));
                    }
                    catch (Exception e)
                    {
                        Trace.TraceWarning("MarshallerChannel.NotifyAllWAtchers-Failed exception={0}", e);
                    }
                }

                this.watchers.Clear();
            }
        }