/// <summary>
        /// Raises the FileChanged event
        /// </summary>
        /// <param name="e"></param>
        protected virtual void OnFileChanged(LocalServerDiscoveryFileEventArgs e)
        {
            LocalServerDiscoveryFileEventHandler handler = FileChanged;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Example #2
0
        private void DiscoveryFileMonitorOnFileDeleted(object sender, LocalServerDiscoveryFileEventArgs e)
        {
            LiveSessionPublisher victim;

            //this event *should* mean that we have to dump a proxy we were connected to...
            lock (m_LocalProxyConnections)
            {
                if (m_LocalProxyConnections.TryGetValue(e.File.FileNamePath, out victim))
                {
                    if (victim != null)
                    {
                        m_LocalProxyConnections.Remove(e.File.FileNamePath);
                    }
                }
            }

            CloseClient(victim);
        }
Example #3
0
        private void DiscoveryFileMonitorOnFileChanged(object sender, LocalServerDiscoveryFileEventArgs e)
        {
            LiveSessionPublisher target;

            //this event *should* mean that we have a new proxy to connect to...
            lock (m_LocalProxyConnections)
            {
                if (!m_LocalProxyConnections.TryGetValue(e.File.FileNamePath, out target))
                {
                    if (e.File.IsAlive)
                    {
                        target = new LiveSessionPublisher(this, e.File);
                        target.Start();
                        m_LocalProxyConnections.Add(e.File.FileNamePath, target);
                    }
                }
            }
        }
        private void CheckRaiseChangedEvent(string fullPath)
        {
            LocalServerDiscoveryFileEventArgs eventArgs = null;

            lock (m_Lock)
            {
                LocalServerDiscoveryFile newItem = null;
                if (!m_DiscoveryFiles.ContainsKey(fullPath))
                {
                    //we don't actually process change events, only adds.
                    try
                    {
                        newItem = new LocalServerDiscoveryFile(fullPath);
                        if (newItem.IsAlive)
                        {
                            m_DiscoveryFiles.Add(fullPath, newItem);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (!Log.SilentMode)
                        {
                            Log.Write(LogMessageSeverity.Information, NetworkMessenger.LogCategory, "Unable to load local server discovery file due to " + ex.GetType() + " exception",
                                      "While attempting to load a local server discovery file an exception was thrown.  If this is because the file wasn't found " +
                                      "or was incomplete it can be ignored.  An incomplete file will raise another event when complete that will cause it to be re-processed.\r\n" +
                                      "File: {0}\r\nException: {1}", fullPath, ex.Message);
                        }
                    }

                    if (newItem != null)
                    {
                        eventArgs = new LocalServerDiscoveryFileEventArgs(newItem);
                    }
                }
            }

            //raise the event outside of our lock
            if (eventArgs != null)
            {
                OnFileChanged(eventArgs);
            }
        }
        private void CheckRaiseDeletedEvent(string fullPath)
        {
            LocalServerDiscoveryFileEventArgs eventArgs = null;

            lock (m_Lock)
            {
                LocalServerDiscoveryFile victim;
                if (m_DiscoveryFiles.TryGetValue(fullPath, out victim))
                {
                    //indeed it existed so we want to raise the event.
                    m_DiscoveryFiles.Remove(fullPath);
                    eventArgs = new LocalServerDiscoveryFileEventArgs(victim);
                }
            }

            //raise the event outside of the lock.
            if (eventArgs != null)
            {
                OnFileDeleted(eventArgs);
            }
        }