Example #1
0
        public LoginController(ILogger logger, IEventManager events, IRpcHandler rpc, IRconManager rcon, Configuration configuration) : base(logger, events, rpc, rcon, configuration)
        {
            this.BCryptHelper = new BCryptHelper(this.Configuration.GlobalSalt, this.Configuration.BCryptCost);

            this.LoginAttempts    = new Dictionary <int, int>();
            this.LoggedInAccounts = new List <Account>();

            // Send configuration when requested
            this.Rpc.Event(LoginEvents.Configuration).On(e => e.Reply(new PublicConfiguration(this.Configuration)));

            this.Rpc.Event(LoginEvents.Register).On <string, string>(OnRegistrationRequested);
            this.Rpc.Event(LoginEvents.Login).On <string, string>(OnLoginRequested);
            this.Rpc.Event(LoginEvents.AuthenticationStarted).On(OnAuthenticationStarted);

            this.Events.OnRequest(LoginEvents.GetCurrentAccountsCount, () => this.LoggedInAccounts.Count);
            this.Events.OnRequest(LoginEvents.GetCurrentAccounts, () => this.LoggedInAccounts);

            // Listen for NFive SessionManager plugin events
            var sessions = new SessionManager.Server.SessionManager(this.Events, this.Rpc);

            sessions.ClientDisconnected += OnClientDisconnected;
        }
Example #2
0
        public GateGuardController(ILogger logger, IEventManager events, IRpcHandler rpc, IRconManager rcon, Configuration configuration) : base(logger, events, rpc, rcon, configuration)
        {
            this.Logger.Info($"Running in {this.Configuration.Mode.ToString().ToLower()} mode");
            this.Logger.Info($"Database update interval: Every {this.Configuration.Database.ReloadInterval.ToFriendly()}");

            this.Rpc.Event(GateGuardEvents.RuleCreate).On <Guid, GateGuard.AccessRule, string, DateTime?>(OnRuleCreate);
            this.Rpc.Event(GateGuardEvents.RuleDelete).On <Guid>(OnRuleDelete);

            // Listen for NFive SessionManager plugin events
            var sessions = new SessionManager.Server.SessionManager(this.Events, this.Rpc);

            sessions.SessionCreated += OnSessionCreated;

            // ReSharper disable once FunctionNeverReturns
            Task.Factory.StartNew(async() =>
            {
                while (true)
                {
                    Load();

                    await Task.Delay(this.Configuration.Database.ReloadInterval);
                }
            });
        }