예제 #1
0
 private void HandleRtmpt()
 {
     if (this._rtmptRequest == null)
     {
         string             str5;
         BufferStreamReader reader     = new BufferStreamReader(this._readBuffer);
         string[]           strArray   = reader.ReadLine().Split(new char[] { ' ' });
         string             httpMethod = strArray[0];
         string             pattern    = strArray[1];
         int startIndex = 0;
         while ((startIndex = pattern.IndexOf("%", startIndex)) != -1)
         {
             pattern = pattern.Substring(0, startIndex) + Uri.HexUnescape(pattern, ref startIndex) + pattern.Substring(startIndex);
         }
         string    protocol = strArray[2];
         Hashtable headers  = new Hashtable();
         string    str6     = null;
         while (((str5 = reader.ReadLine()) != null) && (str5 != string.Empty))
         {
             if ((str6 != null) && char.IsWhiteSpace(str5[0]))
             {
                 Hashtable hashtable2;
                 object    obj2;
                 (hashtable2 = headers)[obj2 = str6] = hashtable2[obj2] + str5;
             }
             else
             {
                 int index = str5.IndexOf(":");
                 if (index != -1)
                 {
                     str6 = str5.Substring(0, index);
                     string str7 = str5.Substring(index + 1).Trim();
                     headers[str6] = str7;
                 }
                 else
                 {
                     break;
                 }
             }
         }
         this._rtmptRequest = new RtmptRequest(this, pattern, protocol, httpMethod, headers);
     }
     if (this._readBuffer.Remaining == this._rtmptRequest.ContentLength)
     {
         RtmptEndpoint endpoint = this.Endpoint.GetMessageBroker().GetEndpoint("__@fluorinertmpt") as RtmptEndpoint;
         if (endpoint != null)
         {
             this._readBuffer.Compact();
             this._rtmptRequest.Data = this._readBuffer;
             this._readBuffer        = ByteBuffer.Allocate(0x1000);
             this._readBuffer.Flip();
             endpoint.Service(this._rtmptRequest);
             this._rtmptRequest = null;
         }
     }
 }
        private void HandleRtmpt(RtmptRequest rtmptRequest)
        {
            IEndpoint     endpoint      = this.Endpoint.GetMessageBroker().GetEndpoint(RtmptEndpoint.FluorineRtmptEndpointId);
            RtmptEndpoint rtmptEndpoint = endpoint as RtmptEndpoint;

            if (rtmptEndpoint != null)
            {
                rtmptEndpoint.Service(rtmptRequest);
            }
        }
예제 #3
0
        /// <summary>
        /// This method supports the Fluorine infrastructure and is not intended to be used directly from your code.
        /// </summary>
        /// <param name="configFolderPaths">Possible configuration file locations.</param>
        /// <param name="serviceBrowserAvailable">Indicates whether the service browser is avaliable.</param>
        public void Init(string[] configFolderPaths, bool serviceBrowserAvailable)
        {
            _messageBroker = new MessageBroker(this);

            string servicesConfigFile = null;

            for (int i = 0; i < configFolderPaths.Length; i++)
            {
                servicesConfigFile = Path.Combine(configFolderPaths[i], "services-config.xml");
                if (log.IsDebugEnabled)
                {
                    log.Debug(__Res.GetString(__Res.MessageServer_TryingServiceConfig, servicesConfigFile));
                }
                if (File.Exists(servicesConfigFile))
                {
                    break;
                }
            }
            if (servicesConfigFile != null && File.Exists(servicesConfigFile))
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug(__Res.GetString(__Res.MessageServer_LoadingServiceConfig, servicesConfigFile));
                }
                _servicesConfiguration = ServicesConfiguration.Load(servicesConfigFile);
            }
            else
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug(__Res.GetString(__Res.MessageServer_LoadingConfigDefault));
                }
                _servicesConfiguration = ServicesConfiguration.CreateDefault();
            }

            foreach (ChannelDefinition channelDefinition in _servicesConfiguration.Channels)
            {
                Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(channelDefinition.Endpoint.Class));
                if (type != null)
                {
                    IEndpoint endpoint = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, channelDefinition }) as IEndpoint;
                    if (endpoint != null)
                    {
                        _messageBroker.AddEndpoint(endpoint);
                    }
                }
                else
                {
                    log.Error(__Res.GetString(__Res.Type_InitError, channelDefinition.Class));
                }
            }
            ChannelDefinition rtmptChannelDefinition = new ChannelDefinition();

            rtmptChannelDefinition.Id = RtmptEndpoint.FluorineRtmptEndpointId;
            IEndpoint rtmptEndpoint = new RtmptEndpoint(_messageBroker, rtmptChannelDefinition);

            _messageBroker.AddEndpoint(rtmptEndpoint);

            if (_servicesConfiguration.Factories != null)
            {
                foreach (Factory factory in _servicesConfiguration.Factories)
                {
                    Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(factory.Class));
                    if (type != null)
                    {
                        IFlexFactory flexFactory = ObjectFactory.CreateInstance(type, new object[0]) as IFlexFactory;
                        if (flexFactory != null)
                        {
                            _messageBroker.AddFactory(factory.Id, flexFactory);
                        }
                    }
                    else
                    {
                        log.Error(__Res.GetString(__Res.Type_InitError, factory.Class));
                    }
                }
            }
            //Add the dotnet Factory
            _messageBroker.AddFactory(DotNetFactory.Id, new DotNetFactory());

            if (serviceBrowserAvailable)
            {
                ServiceDefinition serviceConfiguration = _servicesConfiguration.GetServiceByClass("flex.messaging.services.RemotingService");
                if (serviceConfiguration != null)
                {
                    AdapterDefinition adapter = serviceConfiguration.GetAdapterByClass(typeof(Remoting.RemotingAdapter).FullName);
                    if (adapter != null)
                    {
                        InstallServiceBrowserDestinations(serviceConfiguration, adapter);
                    }
                    else
                    {
                        adapter = serviceConfiguration.GetDefaultAdapter();
                        if (adapter != null)
                        {
                            InstallServiceBrowserDestinations(serviceConfiguration, adapter);
                        }
                    }
                }
            }
            if (_servicesConfiguration.Services.ServiceDefinitions != null)
            {
                foreach (ServiceDefinition serviceDefinition in _servicesConfiguration.Services.ServiceDefinitions)
                {
                    Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(serviceDefinition.Class));//current assembly only
                    if (type != null)
                    {
                        IService service = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, serviceDefinition }) as IService;
                        if (service != null)
                        {
                            _messageBroker.AddService(service);
                        }
                    }
                    else
                    {
                        log.Error(__Res.GetString(__Res.Type_InitError, serviceDefinition.Class));
                    }
                }
            }
            if (_servicesConfiguration.Services.Includes != null)
            {
                foreach (ServiceInclude include in _servicesConfiguration.Services.Includes)
                {
                    ServiceDefinition serviceDefinition = include.ServiceDefinition;
                    Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(serviceDefinition.Class));//current assembly only
                    if (type != null)
                    {
                        IService service = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, serviceDefinition }) as IService;
                        if (service != null)
                        {
                            _messageBroker.AddService(service);
                        }
                    }
                    else
                    {
                        log.Error(__Res.GetString(__Res.Type_InitError, serviceDefinition.Class));
                    }
                }
            }
            if (_servicesConfiguration.Security != null)
            {
                if (_servicesConfiguration.Security.LoginCommands != null && _servicesConfiguration.Security.LoginCommands.Length > 0)
                {
                    LoginCommand loginCommand = _servicesConfiguration.Security.GetLoginCommand(LoginCommand.FluorineLoginCommand);
                    if (loginCommand != null)
                    {
                        Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(loginCommand.Class));
                        if (type != null)
                        {
                            ILoginCommand loginCommandObj = ObjectFactory.CreateInstance(type, new object[] { }) as ILoginCommand;
                            _messageBroker.LoginManager.LoginCommand = loginCommandObj;
                            _messageBroker.LoginManager.IsPerClientAuthentication = loginCommand.IsPerClientAuthentication;
                        }
                        else
                        {
                            log.Error(__Res.GetString(__Res.Type_InitError, loginCommand.Class));
                        }
                    }
                    else
                    {
                        log.Error(__Res.GetString(__Res.Type_InitError, "<<LoginCommand class>>"));
                    }
                }
            }
            InitAuthenticationService();

            try
            {
                if (FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings != null &&
                    FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.Enable)
                {
                    IResource resource;
                    if (FluorineContext.Current != null)
                    {
                        resource = FluorineContext.Current.GetResource(FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile);
                    }
                    else
                    {
                        resource = new FileSystemResource(FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile);
                    }
                    if (resource.Exists)
                    {
                        log.Info(__Res.GetString(__Res.Silverlight_StartPS, resource.File.FullName));
                        _policyServer = new PolicyServer(resource.File.FullName);
                    }
                    else
                    {
                        throw new FileNotFoundException("Policy file not found", FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(__Res.GetString(__Res.Silverlight_PSError), ex);
            }
        }
예제 #4
0
        public void Init(string configPath, bool serviceBrowserAvailable)
        {
            Type type;

            this._messageBroker         = new FluorineFx.Messaging.MessageBroker(this);
            this._serviceConfigSettings = FluorineFx.Messaging.Config.ServiceConfigSettings.Load(configPath, "services-config.xml");
            foreach (ChannelSettings settings in this._serviceConfigSettings.ChannelsSettings)
            {
                type = ObjectFactory.Locate(settings.Class);
                if (type != null)
                {
                    IEndpoint endpoint = ObjectFactory.CreateInstance(type, new object[] { this._messageBroker, settings }) as IEndpoint;
                    if (endpoint != null)
                    {
                        this._messageBroker.AddEndpoint(endpoint);
                    }
                }
                else
                {
                    log.Error(__Res.GetString("Type_InitError", new object[] { settings.Class }));
                }
                ChannelSettings channelSettings = new ChannelSettings("__@fluorinertmpt", null);
                IEndpoint       endpoint2       = new RtmptEndpoint(this._messageBroker, channelSettings);
                this._messageBroker.AddEndpoint(endpoint2);
            }
            foreach (FactorySettings settings3 in this._serviceConfigSettings.FactoriesSettings)
            {
                type = ObjectFactory.Locate(settings3.ClassId);
                if (type != null)
                {
                    IFlexFactory factory = ObjectFactory.CreateInstance(type, new object[0]) as IFlexFactory;
                    if (factory != null)
                    {
                        this._messageBroker.AddFactory(settings3.Id, factory);
                    }
                }
                else
                {
                    log.Error(__Res.GetString("Type_InitError", new object[] { settings3.ClassId }));
                }
            }
            this._messageBroker.AddFactory("dotnet", new DotNetFactory());
            if (serviceBrowserAvailable && (this._serviceConfigSettings.ServiceSettings["remoting-service"] != null))
            {
                ServiceSettings serviceSettings = this._serviceConfigSettings.ServiceSettings["remoting-service"];
                AdapterSettings adapterSettings = this._serviceConfigSettings.ServiceSettings["remoting-service"].AdapterSettings["dotnet"];
                this.InstallServiceBrowserDestinations(serviceSettings, adapterSettings);
            }
            foreach (ServiceSettings settings6 in this._serviceConfigSettings.ServiceSettings)
            {
                type = ObjectFactory.Locate(settings6.Class);
                if (type != null)
                {
                    IService service = ObjectFactory.CreateInstance(type, new object[] { this._messageBroker, settings6 }) as IService;
                    if (service != null)
                    {
                        this._messageBroker.AddService(service);
                    }
                }
                else
                {
                    log.Error(__Res.GetString("Type_InitError", new object[] { settings6.Class }));
                }
            }
            if ((this._serviceConfigSettings.SecuritySettings != null) && ((this._serviceConfigSettings.SecuritySettings.LoginCommands != null) && (this._serviceConfigSettings.SecuritySettings.LoginCommands.Count > 0)))
            {
                string loginCommand = this._serviceConfigSettings.SecuritySettings.LoginCommands.GetLoginCommand("asp.net");
                type = ObjectFactory.Locate(loginCommand);
                if (type != null)
                {
                    ILoginCommand command = ObjectFactory.CreateInstance(type, new object[0]) as ILoginCommand;
                    this._messageBroker.LoginCommand = command;
                }
                else
                {
                    log.Error(__Res.GetString("Type_InitError", new object[] { loginCommand }));
                }
            }
            this.InitAuthenticationService();
            try
            {
                if ((FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings != null) && FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.Enable)
                {
                    IResource resource = FluorineContext.Current.GetResource(FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile);
                    if (!resource.Exists)
                    {
                        throw new FileNotFoundException("Policy file not found", FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile);
                    }
                    log.Info(__Res.GetString("Silverlight_StartPS", new object[] { resource.File.FullName }));
                    this._policyServer = new PolicyServer(resource.File.FullName);
                }
            }
            catch (Exception exception)
            {
                log.Error(__Res.GetString("Silverlight_PSError"), exception);
            }
        }
예제 #5
0
 public RtmptServer(RtmptEndpoint endpoint)
 {
     _connections = new SynchronizedHashtable();
     _endpoint    = endpoint;
     _rtmpHandler = new RtmpHandler(endpoint);
 }
예제 #6
0
 public RtmptServer(RtmptEndpoint endpoint)
 {
     this._endpoint    = endpoint;
     this._rtmpHandler = new FluorineFx.Messaging.Rtmp.RtmpHandler(endpoint);
 }