private void MediaServerCoreDebugSink(UPnPMediaServer sender, string msg) { OpenSource.Utilities.EventLogger.Log(sender,System.Diagnostics.EventLogEntryType.Information,msg); }
private void Connect() { if (mediaServer != null) Disconnect(); if (registeredServerType == false) { OpenSource.Utilities.EventLogger.Log(this,System.Diagnostics.EventLogEntryType.Information,"RegisterWellKnownClientType"); RemotingConfiguration.RegisterWellKnownClientType( typeof(UPnPMediaServer), "http://localhost:12329/UPnPMediaServer/UPnPMediaServer.soap" ); registeredServerType = true; } mediaServer = new UPnPMediaServer(); OpenSource.Utilities.EventLogger.Log(this,System.Diagnostics.EventLogEntryType.Information,"New UPnPMediaServer"); /* mediaServer.OnStatsChanged += new MediaServerCore.MediaServerCoreEventHandler(MediaServerStatsChangedSink); mediaServer.OnHttpTransfersChanged += new MediaServerCore.MediaServerCoreEventHandler(MediaHttpTransferssChangedSink); mediaServer.OnDebugMessage += new MediaServerCore.MediaServerCoreDebugHandler(MediaServerCoreDebugSink); */ }
private void Disconnect() { /* mediaServer.OnStatsChanged += new MediaServerCore.MediaServerCoreEventHandler(MediaServerStatsChangedSink); mediaServer.OnHttpTransfersChanged += new MediaServerCore.MediaServerCoreEventHandler(MediaHttpTransferssChangedSink); mediaServer.OnDebugMessage += new MediaServerCore.MediaServerCoreDebugHandler(MediaServerCoreDebugSink); */ mediaServer = null; }
public MainForm(string[] args) { // // Required for Windows Form Designer support // InitializeComponent(); OpenSource.UPnP.DText p = new OpenSource.UPnP.DText(); p.ATTRMARK = "="; string[] filePaths = new string[1]; foreach(string arg in args) { p[0] = arg; switch(p[1].ToUpper()) { case "-UDN": MediaServerCore.CustomUDN = p[2]; break; case "-CACHETIME": MediaServerCore.CacheTime = int.Parse(p[2]); break; case "-INMPR": MediaServerCore.INMPR = !(p[2].ToUpper()=="NO"); break; } } // Setup the UI transfersSplitter.Visible = viewTransfersPanelMenuItem.Checked; transfersListView.Visible = viewTransfersPanelMenuItem.Checked; try { serviceController = new ServiceController("UPnP Media Server"); serviceStatus = serviceController.Status; OpenSource.Utilities.EventLogger.Log(this,System.Diagnostics.EventLogEntryType.Information,"Service control mode..."); } catch (System.InvalidOperationException) { serviceController = null; serviceStatus = ServiceControllerStatus.Stopped; OpenSource.Utilities.EventLogger.Log(this,System.Diagnostics.EventLogEntryType.Information,"Stand alone mode..."); } if (serviceController != null) { // Service controller mode serviceMenuItem.Visible = true; // Pause State pauseServerMenuItem.Visible = false; System.Collections.Specialized.ListDictionary channelProperties = new System.Collections.Specialized.ListDictionary(); channelProperties.Add("port", 12330); HttpChannel channel = new HttpChannel(channelProperties, new SoapClientFormatterSinkProvider(), new SoapServerFormatterSinkProvider()); ChannelServices.RegisterChannel(channel, false); OpenSource.Utilities.EventLogger.Log(this,System.Diagnostics.EventLogEntryType.Information,"RegisterChannel"); if (serviceStatus == ServiceControllerStatus.Running) { OpenSource.Utilities.EventLogger.Log(this,System.Diagnostics.EventLogEntryType.Information,"RegisterWellKnownClientType"); RemotingConfiguration.RegisterWellKnownClientType( typeof(UPnPMediaServer), "http://localhost:12329/UPnPMediaServer/UPnPMediaServer.soap" ); registeredServerType = true; } } else { // Stand alone mode if (registeredServerType == true || standAloneMode == true) return; standAloneMode = true; serviceMenuItem.Visible = false; // Stand alone mode mediaServerCore = new MediaServerCore("Media Server (" + System.Windows.Forms.SystemInformation.ComputerName + ")"); this.mediaServerCore.OnDirectoriesChanged += new MediaServerCore.MediaServerCoreEventHandler(this.Sink_OnDirectoriesChanged); mediaServer = new UPnPMediaServer(); // Pause State pauseServerMenuItem.Checked = this.mediaServerCore.IsPaused; } UpdateServiceUI(); foreach(string arg in args) { p[0] = arg; switch(p[1].ToUpper()) { case "-P": filePaths[0] = p[2]; try { this.AddDirs(filePaths); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } break; } } }