public override void Initialize(IServer server) { Database = Msf.Server.DbAccessors.GetAccessor <IProfilesDatabase>(); if (Database == null) { Logger.Error("Profiles database implementation was not found"); } server.SetHandler((short)MsfOpCodes.ClientProfileRequest, HandleClientProfileRequest); // Auth dependency setup _auth = server.GetModule <AuthModule>(); if (_auth != null) { _auth.LoggedIn += OnLoggedIn; } // Games dependency setup server.SetHandler((short)MsfOpCodes.ServerProfileRequest, HandleGameServerProfileRequest); server.SetHandler((short)MsfOpCodes.UpdateServerProfile, HandleProfileUpdates); }
public CockroachDbPlugin(IServer server) : base(server) { var config = SpeedDateConfig.GetPluginConfig <CockroachDbConfig>(); try { var connStringBuilder = new NpgsqlConnectionStringBuilder { Host = config.Host, Port = config.Port, Username = config.Username, Password = config.Password, Database = config.Database }; var connectionString = CommandLineArgs.IsProvided(CommandLineArgs.Names.DbConnectionString) ? CommandLineArgs.DbConnectionString : connStringBuilder.ConnectionString; if (config.CheckConnectionOnStartup) { using (var con = new NpgsqlConnection(connectionString)) { con.Open(); } } AuthDatabase = new AuthDbCockroachDb(connectionString); ProfilesDatabase = new ProfilesDbCockroachDb(connectionString); } catch { Logs.Error("Failed to connect to database"); throw; } }
public override void DoAwake(ServerConfigInfo info) { base.DoAwake(info); _authDb = new AuthDbLdb(new LiteDatabase(@"auth.db")); _profilesDb = new ProfilesDatabaseLdb(new LiteDatabase(@"profiles.db")); }