using System;
using System.Collections.Generic;
using System.Threading.Tasks;
///
/// 动态配置模块。
///
public sealed class BriskConfigModule
: BriskModuleBase
{
///
/// 获取当前客户端命中的动态配置。
///
public async Task GetCurrentAsync()
{
return await ExecutePublicAsync(async context =>
{
var data = await context.HttpClient.GetDataAsync("/config/current", CreateQuery(context), false);
return BriskModelMapper.ToConfigCurrent(data);
});
}
///
/// 刷新并重新获取动态配置。
///
public Task RefreshAsync()
{
return GetCurrentAsync();
}
private static Dictionary CreateQuery(BriskContext context)
{
return new Dictionary
{
{ "game_key", context.Options.GameKey },
{ "client_version", context.Options.ClientVersion }
};
}
}