Feature: expose profile save wait delay in config
This commit is contained in:
parent
a207e5778e
commit
a5272dc596
@ -2,5 +2,6 @@
|
|||||||
"akiVersion": "3.5.4",
|
"akiVersion": "3.5.4",
|
||||||
"projectName": "SPT-AKI",
|
"projectName": "SPT-AKI",
|
||||||
"compatibleTarkovVersion": "0.13.0.22173",
|
"compatibleTarkovVersion": "0.13.0.22173",
|
||||||
"serverName": "SPT Server"
|
"serverName": "SPT Server",
|
||||||
|
"profileSaveIntervalSeconds": 15
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,23 @@
|
|||||||
import { inject, injectable } from "tsyringe";
|
import { inject, injectable } from "tsyringe";
|
||||||
|
|
||||||
import { OnLoad } from "../di/OnLoad";
|
import { OnLoad } from "../di/OnLoad";
|
||||||
import { OnUpdate } from "../di/OnUpdate";
|
import { OnUpdate } from "../di/OnUpdate";
|
||||||
|
import { ConfigTypes } from "../models/enums/ConfigTypes";
|
||||||
|
import { ICoreConfig } from "../models/spt/config/ICoreConfig";
|
||||||
|
import { ConfigServer } from "../servers/ConfigServer";
|
||||||
import { SaveServer } from "../servers/SaveServer";
|
import { SaveServer } from "../servers/SaveServer";
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class SaveCallbacks implements OnLoad, OnUpdate
|
export class SaveCallbacks implements OnLoad, OnUpdate
|
||||||
{
|
{
|
||||||
|
protected coreConfig: ICoreConfig;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@inject("SaveServer") protected saveServer: SaveServer
|
@inject("SaveServer") protected saveServer: SaveServer,
|
||||||
|
@inject("ConfigServer") protected configServer: ConfigServer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
this.coreConfig = this.configServer.getConfig(ConfigTypes.CORE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async onLoad(): Promise<void>
|
public async onLoad(): Promise<void>
|
||||||
@ -26,7 +33,7 @@ export class SaveCallbacks implements OnLoad, OnUpdate
|
|||||||
public async onUpdate(secondsSinceLastRun: number): Promise<boolean>
|
public async onUpdate(secondsSinceLastRun: number): Promise<boolean>
|
||||||
{
|
{
|
||||||
// run every 15 seconds
|
// run every 15 seconds
|
||||||
if (secondsSinceLastRun > 15)
|
if (secondsSinceLastRun > this.coreConfig.profileSaveIntervalSeconds)
|
||||||
{
|
{
|
||||||
this.saveServer.save();
|
this.saveServer.save();
|
||||||
return true;
|
return true;
|
||||||
|
@ -5,7 +5,8 @@ export interface ICoreConfig extends IBaseConfig
|
|||||||
kind: "aki-core"
|
kind: "aki-core"
|
||||||
akiVersion: string
|
akiVersion: string
|
||||||
projectName: string
|
projectName: string
|
||||||
compatibleTarkovVersion: string,
|
compatibleTarkovVersion: string
|
||||||
serverName: string;
|
serverName: string
|
||||||
|
profileSaveIntervalSeconds: number
|
||||||
commit: string
|
commit: string
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user