Exemple #1
0
        protected void CreateServerHandler(uint port, string urlPath, string serverHandlerName)
        {
            IHttpServer server = m_registry.RequestModuleInterface <ISimulationBase>().GetHttpServer(port);

            server.AddStreamHandler(new ServerHandler(urlPath, m_registry, this));
            ConnectorRegistry.RegisterServerHandlerConnector(this);
            m_startedServer = true;
        }
Exemple #2
0
        public void Init(IRegistryCore registry, string name, string password = "", string serverPath = "", string serverHandlerName = "")
        {
            Enabled    = true;
            m_registry = registry;
            m_name     = name;
            m_password = password;
            bool            openServerHandler = false;
            uint            serverHandlerPort = 0;
            ISimulationBase simBase           = registry == null ? null : registry.RequestModuleInterface <ISimulationBase>();

            if (simBase != null)
            {
                IConfigSource source = registry.RequestModuleInterface <ISimulationBase>().ConfigSource;
                IConfig       config;
                if ((config = source.Configs["WhiteCoreConnectors"]) != null)
                {
                    m_doRemoteCalls = config.Contains(name + "DoRemoteCalls")
                                          ? config.GetBoolean(name + "DoRemoteCalls", false)
                                          : config.GetBoolean("DoRemoteCalls", false);

                    if ((config = source.Configs["Handlers"]) != null)
                    {
                        openServerHandler = config.GetBoolean(name + "OpenServerHandler", false);
                        serverHandlerPort = config.GetUInt(name + "ServerHandlerPort", serverHandlerPort);
                    }
                }
                if ((config = source.Configs["Configuration"]) != null)
                {
                    m_OSDRequestTryCount = config.GetInt("OSDRequestTryCount", m_OSDRequestTryCount);
                }
            }
            if (m_doRemoteCalls)
            {
                m_doRemoteOnly = true; //Lock out local + remote for now
            }
            ConnectorRegistry.RegisterConnector(this);

            ServerHandlerName = serverHandlerName;
            if (MainServer.Instance == null && serverHandlerPort == 0)
            {
                openServerHandler = false;
            }
            else
            {
                ServerHandlerPort = serverHandlerPort == 0 ? MainServer.Instance.Port : serverHandlerPort;
                ServerHandlerPath = serverPath;
            }

            if (openServerHandler)
            {
                CreateServerHandler(serverHandlerPort, serverPath, serverHandlerName);
            }
        }