Esempio n. 1
0
        private bool Init()
        {
            lock (_filesSync)
            {
                if (_disposed)
                {
                    return(false);
                }

                if (_web == null)
                {
                    var options = new StartOptions
                    {
                        ServerFactory = "Nowin",
                        Port          = _multimediaPort
                    };

                    try
                    {
                        _web = WebApp.Start <Startup>(options);
                    }
                    catch (TargetInvocationException exc)
                        when(exc.InnerException is SocketException socketException &&
                             socketException.NativeErrorCode == AddressIsUsedErrorCode)
                        {
                            throw new PortIsUsedException();
                        }

                    Current = this;
                }
            }

            return(true);
        }
Esempio n. 2
0
        public override void Dispose()
        {
            lock (_filesSync)
            {
                StopURI(_files.Keys.ToArray());

                if (_web != null)
                {
                    _web.Dispose();
                    _web = null;
                }

                _disposed = true;

                Current = null;
            }
        }
Esempio n. 3
0
        private bool Init()
        {
            lock (_filesSync)
            {
                if (_disposed)
                {
                    return false;
                }

                if (_web == null)
                {
                    var options = new StartOptions
                    {
                        ServerFactory = "Nowin",
                        Port = _multimediaPort
                    };

                    _web = WebApp.Start<Startup>(options);
                    Current = this;
                }
            }

            return true;
        }