コード例 #1
0
 internal ChannelSettings(string id, string endpointClass, string endpointUri)
     : this()
 {
     _id            = id;
     _endpointClass = endpointClass;
     _endpointUri   = endpointUri;
     _uri           = new UriBase(_endpointUri);
 }
コード例 #2
0
        public void Init(PipelineContext ctx, XmlNode node)
        {
            processName = node.ReadStr("@tikaprocess");
            UriBase     = node.ReadStr("@tikaurl");
            if (!UriBase.EndsWith("/"))
            {
                UriBase += "/";
            }
            streamDirectory = new RootStreamDirectory(ctx, node);
            abstractLength  = node.ReadInt("abstract/@maxlength", 256);
            abstractDelta   = node.ReadInt("abstract/@delta", 20);
            DbgStoreDir     = node.ReadStr("dbgstore", null);
            if (DbgStoreDir != null)
            {
                DbgStoreDir = IOUtils.AddSlash(ctx.ImportEngine.Xml.CombinePath(DbgStoreDir));
                IOUtils.ForceDirectories(DbgStoreDir, true);
            }
            ctx.ImportLog.Log("dbgstore dir={0}", DbgStoreDir ?? "NULL");

            pingUrl          = node.ReadStr("@pingurl", null);
            pingTimeout      = node.ReadInt("@pingtimeout", 10000);
            maxParallel      = node.ReadInt("@maxparallel", 1);
            mustEmitSecurity = node.ReadBool("security/@emit", false);
        }
コード例 #3
0
ファイル: RtmpEndpoint.cs プロジェクト: Joy011024/PickUpData
 public override void Start()
 {
     try
     {
         string     str;
         IPEndPoint point;
         if (log.get_IsInfoEnabled())
         {
             log.Info(__Res.GetString("RtmpEndpoint_Start"));
         }
         IGlobalScope globalScope = base.GetMessageBroker().GlobalScope;
         if (FluorineContext.Current != null)
         {
             str = Path.Combine(FluorineContext.Current.ApplicationBaseDirectory, "apps");
         }
         else
         {
             str = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "apps");
         }
         if (Directory.Exists(str))
         {
             foreach (string str2 in Directory.GetDirectories(str))
             {
                 DirectoryInfo            info      = new DirectoryInfo(str2);
                 string                   name      = info.Name;
                 ApplicationConfiguration appConfig = ApplicationConfiguration.Load(Path.Combine(str2, "app.config"));
                 WebScope                 scope2    = new WebScope(this, globalScope, appConfig);
                 ScopeContext             context   = new ScopeContext("/" + name, globalScope.Context.ClientRegistry, globalScope.Context.ScopeResolver, globalScope.Context.ServiceInvoker, null);
                 scope2.Context = context;
                 IScopeHandler handler = ObjectFactory.CreateInstance(appConfig.ApplicationHandler.Type) as IScopeHandler;
                 if (handler == null)
                 {
                     log.Error(__Res.GetString("Type_InitError", new object[] { appConfig.ApplicationHandler.Type }));
                 }
                 scope2.Handler = handler;
                 scope2.SetContextPath("/" + name);
                 scope2.Register();
             }
         }
         this._rtmpServer = new RtmpServer(this);
         UriBase uri  = base._channelSettings.GetUri();
         int     port = 0x78f;
         if ((uri.Port != null) && (uri.Port != string.Empty))
         {
             port = Convert.ToInt32(uri.Port);
         }
         if (log.get_IsInfoEnabled())
         {
             log.Info(__Res.GetString("RtmpEndpoint_Starting", new object[] { port.ToString() }));
         }
         if (base._channelSettings.BindAddress != null)
         {
             point = new IPEndPoint(IPAddress.Parse(base._channelSettings.BindAddress), port);
         }
         else
         {
             point = new IPEndPoint(IPAddress.Any, port);
         }
         this._rtmpServer.AddListener(point);
         this._rtmpServer.OnError += new ErrorHandler(this.OnError);
         this._rtmpServer.Start();
         if (log.get_IsInfoEnabled())
         {
             log.Info(__Res.GetString("RtmpEndpoint_Started"));
         }
     }
     catch (Exception exception)
     {
         if (log.get_IsFatalEnabled())
         {
             log.Fatal("RtmpEndpoint failed", exception);
         }
     }
 }
コード例 #4
0
        public override void Start()
        {
            try
            {
                if (log.IsInfoEnabled)
                {
                    log.Info(__Res.GetString(__Res.RtmpEndpoint_Start));
                }

                //Each Application has its own Scope hierarchy and the root scope is WebScope.
                //There's a global scope that aims to provide common resource sharing across Applications namely GlobalScope.
                //The GlobalScope is the parent of all WebScopes.
                //Other scopes in between are all instances of Scope. Each scope takes a name.
                //The GlobalScope is named "default".
                //The WebScope is named per Application context name.
                //The Scope is named per path name.
                IGlobalScope globalScope = GetMessageBroker().GlobalScope;
                string       baseDirectory;
                if (FluorineContext.Current != null)
                {
                    baseDirectory = Path.Combine(FluorineContext.Current.ApplicationBaseDirectory, "apps");
                }
                else
                {
                    baseDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "apps");
                }
                if (Directory.Exists(baseDirectory))
                {
                    foreach (string appDirectory in Directory.GetDirectories(baseDirectory))
                    {
                        DirectoryInfo            directoryInfo = new DirectoryInfo(appDirectory);
                        string                   appName       = directoryInfo.Name;
                        string                   appConfigFile = Path.Combine(appDirectory, "app.config");
                        ApplicationConfiguration configuration = ApplicationConfiguration.Load(appConfigFile);
                        WebScope                 scope         = new WebScope(this, globalScope, configuration);

                        // Create context for the WebScope and initialize
                        ScopeContext scopeContext = new ScopeContext("/" + appName, globalScope.Context.ClientRegistry, globalScope.Context.ScopeResolver, globalScope.Context.ServiceInvoker, null);
                        // Store context in scope
                        scope.Context = scopeContext;
                        // ApplicationAdapter
                        IFlexFactory    factory         = GetMessageBroker().GetFactory(configuration.ApplicationHandler.Factory);
                        FactoryInstance factoryInstance = factory.CreateFactoryInstance(this.Id, null);
                        if (factoryInstance == null)
                        {
                            string msg = string.Format("Missing factory {0}", configuration.ApplicationHandler.Factory);
                            log.Fatal(msg);
                            throw new NotSupportedException(msg);
                        }
                        factoryInstance.Source = configuration.ApplicationHandler.Type;
                        object        applicationHandlerInstance = factoryInstance.Lookup();
                        IScopeHandler scopeHandler = applicationHandlerInstance as IScopeHandler;
                        if (scopeHandler == null)
                        {
                            log.Error(__Res.GetString(__Res.Type_InitError, configuration.ApplicationHandler.Type));
                            throw new TypeInitializationException(configuration.ApplicationHandler.Type, null);
                        }
                        scope.Handler = scopeHandler;
                        // Make available as "/<directoryName>" and allow access from all hosts
                        scope.SetContextPath("/" + appName);
                        // Register WebScope in server
                        scope.Register();
                    }
                }
                _rtmpServer = new RtmpServer(this);

                UriBase uri = this.ChannelDefinition.GetUri();
                if (uri.Protocol == "http" || uri.Protocol == "https")
                {
                    log.Info(string.Format("Rtmp endpoint was not started, specified protocol: {0}", uri.Protocol));
                    return;
                }
                int port = 1935;
                if (uri.Port != null && uri.Port != string.Empty)
                {
                    try
                    {
                        port = System.Convert.ToInt32(uri.Port);
                    }
                    catch (FormatException ex)
                    {
                        log.Error("Invalid port", ex);
                        return;
                    }
                }
                if (log.IsInfoEnabled)
                {
                    log.Info(__Res.GetString(__Res.RtmpEndpoint_Starting, port.ToString()));
                }

                IPEndPoint ipEndPoint;
                if (this.ChannelDefinition.Properties.BindAddress != null)
                {
                    IPAddress ipAddress = IPAddress.Parse(this.ChannelDefinition.Properties.BindAddress);
                    ipEndPoint = new IPEndPoint(ipAddress, port);
                }
                else
                {
                    ipEndPoint = new IPEndPoint(IPAddress.Any, port);
                }
                _rtmpServer.AddListener(ipEndPoint);
                _rtmpServer.OnError += new ErrorHandler(OnError);
                _rtmpServer.Start();

                if (log.IsInfoEnabled)
                {
                    log.Info(__Res.GetString(__Res.RtmpEndpoint_Started));
                }
            }
            catch (Exception ex)
            {
                if (log.IsFatalEnabled)
                {
                    log.Fatal("RtmpEndpoint failed", ex);
                }
            }
        }
コード例 #5
0
 /// <inheritdoc/>
 public override int GetHashCode() => ModelID.GetHashCode()
 ^ SubscriptionKey.GetHashCode()
 ^ UriBase.GetHashCode()
 ^ ApiVersion.GetHashCode();