public void Initialize()
        {
            _timer          = new System.Timers.Timer(RecentIPsUpdateRate.TotalMilliseconds);
            _timer.Elapsed += OnTimerIntervalElapsed;

            _recent_server_creators_IPs = new Queue <TimestampedIP>();

            _tcp_listener = new TcpListener(Socket);

            DbServer   = new DatabaseServer();
            AuthServer = new AuthenticationServer.AuthenticationServer(_tcp_listener, DbServer);

            DbServer.Initialize();

            _registered_servers = DbServer.SelectActiveGameServers();

            AuthServer.Initialize();

            _thread_mre = new ManualResetEvent(false);
            _main_mre   = new ManualResetEvent(false);

            _network_handling_thread = new Thread(ServerLoop);
            _network_handling_thread.IsBackground = false;



            Status = ServerStatus.Initialized;
            OnInitialization?.Invoke(this, null);
        }
Exemple #2
0
        private void ReadCommands(string messageData)
        {
            List <string> commands = messageData.Split(';')?.ToList();

            Parallel.ForEach(commands, (command) =>
            {
                string data = command.Split('|')?.ToList().Last();

                if (command.Contains(ELEVATION_COMMAND))
                {
                    OnElevationChange?.Invoke(this, data);
                }
                else if (command.Contains(PITCH_COMMAND))
                {
                    OnPitchChange?.Invoke(this, data);
                }
                else if (command.Contains(ROLL_COMMAND))
                {
                    OnRollChange?.Invoke(this, data);
                }
                else if (command.Contains(ASKSTATUS_COMMAND))
                {
                    OnAskStatus?.Invoke(this, new EventArgs());
                }
                else if (command.Contains(INITIALIZATION_COMMAND))
                {
                    OnInitialization?.Invoke(this, new EventArgs());
                }
            });
        }
Exemple #3
0
 public void Initialize(string categoryID, string itemID)
 {
     ID = new CustomizationID {
         categoryID = categoryID, itemID = itemID
     };
     OnInitialization.Dispatch(ID);
 }
        public async Task Initialize()
        {
            try
            {
                lock (sync)
                {
                    if (IsInitializing)
                    {
                        throw new Exception("The application is already initializing");
                    }
                    IsInitializing = true;
                    Initialized    = false;
                }

                var configurations = await new Uri(string.Format("{0}publicapi/apps?name={1}", marketPlaceUri, Name)).ExecuteAsync <JArray>(this);

                lock (sync)
                {
                    if (configurations.Data.Count > 0)
                    {
                        this.ApplicationConfiguration = configurations.Data[0] as JObject;
                        AllocServices(configurations.Data[0] as JObject);
                        Initialized = true;
                    }
                    else
                    {
                        IsInitializing = false;
                        throw new Exception("Can not get application's configuration");
                    }

                    if (OnInitialization != null)
                    {
                        Task.Run(() =>
                        {
                            OnInitialization.Invoke(this, new EventArgs());
                        }
                                 );
                    }
                }
            }
            catch (Exception e)
            {
                IsInitializing = false;
                throw;
            }

            return;
        }
        /// <summary>
        ///     Creates a new Python Environment and sets up the scope.
        /// </summary>
        public PythonEnvironment(object scope = null, bool redirectOutput = true)
        {
            // Initialize engine
            if (Engine == null)
            {
                InitializeEngine();
            }

            // Initialize scope
            if (scope == null)
            {
                _scope = _scriptEngine.GetMethods()
                         .Single(method =>
                                 method.Name == "CreateScope" &&
                                 method.GetParameters().Count() == 0)
                         .Invoke(Engine, null);
            }
            else
            {
                _scope = scope;
            }

            // Set up environment
            Execute("import sys");
            Execute("sys.modules.clear()");
            Execute("import clr");
            Execute("clr.AddReference(\"System\")");
            Execute("clr.AddReference(\"UnityEngine\")");
            Execute("from UnityEngine import Vector2, Vector3, Vector4, Mathf, Time, Input, KeyCode, Color");

            Execute("clr.AddReference(\"LenchScripterMod\")");
            Execute("from Lench.Scripter import Functions as Besiege");

            // Redirect standard output
            if (redirectOutput)
            {
                this["pythonenv"] = this;
                Execute("sys.stdout = pythonenv");
                Execute("del pythonenv");
            }

            OnInitialization?.Invoke(this);
        }
Exemple #6
0
        public void Initialize()
        {
            _timer          = new System.Timers.Timer(RecentIPsUpdateRate.TotalMilliseconds);
            _timer.Elapsed += OnTimerIntervalElapsed;

            _recent_user_creators_IPs = new Queue <TimestampedIP>();
            _authenticated_users      = new List <DB.User>(AuthorizedUsersInitCapacity);

            _thread_mre = new ManualResetEvent(false);
            _main_mre   = new ManualResetEvent(false);

            _network_handling_thread = new Thread(ServerLoop);
            _network_handling_thread.IsBackground = false;


            Status = ServerStatus.Initialized;

            OnInitialization?.Invoke(this, null);
            //_log_console.AuthenticationInitMessage(); // d
        }
Exemple #7
0
 private void OnOnInitialization()
 {
     OnInitialization?.Invoke();
 }