Add more CloudScript functions, start of EnterMatchmaking
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript;
|
||||
|
||||
public class CloudScriptException : Exception
|
||||
{
|
||||
public CloudScriptException()
|
||||
{
|
||||
}
|
||||
|
||||
protected CloudScriptException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
|
||||
public CloudScriptException(string? message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public CloudScriptException(string? message, Exception? innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Prospect.Server.Api.Services.CloudScript;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class CloudScriptFunction : Attribute
|
||||
{
|
||||
public CloudScriptFunction(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript;
|
||||
|
||||
public record CloudScriptFunctionData(Type Clazz, Type RequestType, bool ReturnsObject, Func<object, object, Task> Delegate);
|
||||
|
||||
public class CloudScriptFunctionLoader
|
||||
{
|
||||
private readonly ILogger<CloudScriptFunctionLoader> _logger;
|
||||
private readonly Dictionary<string, CloudScriptFunctionData> _methods;
|
||||
|
||||
public CloudScriptFunctionLoader(ILogger<CloudScriptFunctionLoader> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_methods = LoadMethods();
|
||||
}
|
||||
|
||||
public bool TryGetFunction(string name, [MaybeNullWhen(false)] out CloudScriptFunctionData functionData)
|
||||
{
|
||||
return _methods.TryGetValue(name, out functionData);
|
||||
}
|
||||
|
||||
private Dictionary<string, CloudScriptFunctionData> LoadMethods()
|
||||
{
|
||||
var result = new Dictionary<string, CloudScriptFunctionData>();
|
||||
|
||||
var genericInterface = typeof(ICloudScriptFunction<,>);
|
||||
|
||||
foreach (var clazz in typeof(CloudScriptFunctionLoader).Assembly.GetTypes())
|
||||
{
|
||||
var attribute = clazz.GetCustomAttribute<CloudScriptFunction>();
|
||||
if (attribute == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var clazzInterface = clazz.GetInterfaces().FirstOrDefault(x => x.IsGenericType && x.GetGenericTypeDefinition() == genericInterface);
|
||||
if (clazzInterface != null)
|
||||
{
|
||||
var genericTypes = clazzInterface.GetGenericArguments();
|
||||
var typeReq = genericTypes[0];
|
||||
var typeRes = genericTypes[1];
|
||||
|
||||
var method = clazz.GetMethod("ExecuteAsync", new []{ typeReq });
|
||||
if (method == null)
|
||||
{
|
||||
_logger.LogWarning("ExecuteAsync method not found for class {Class}", clazz.FullName);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Expression.
|
||||
var argInstance = Expression.Parameter(typeof(object), "instance");
|
||||
var argRequest = Expression.Parameter(typeof(object), "request");
|
||||
|
||||
var invokeReturn = Expression.Label(typeof(Task));
|
||||
|
||||
var invokeArgs = new Expression[]
|
||||
{
|
||||
Expression.Convert(argRequest, typeReq)
|
||||
};
|
||||
|
||||
var invokeCall = Expression.Call(Expression.Convert(argInstance, clazz), method, invokeArgs);
|
||||
|
||||
var invoke = Expression.Block(
|
||||
Expression.Return(invokeReturn, invokeCall),
|
||||
Expression.Label(invokeReturn, Expression.Default(typeof(Task)))
|
||||
);
|
||||
|
||||
var lambda = Expression.Lambda<Func<object, object, Task>>(invoke, argInstance, argRequest).Compile();
|
||||
|
||||
// Store lambda expression.
|
||||
result.Add(attribute.Name, new CloudScriptFunctionData(clazz, typeReq, true, lambda));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript;
|
||||
|
||||
public class CloudScriptService
|
||||
{
|
||||
private readonly ILogger<CloudScriptService> _logger;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private readonly CloudScriptFunctionLoader _functionLoader;
|
||||
|
||||
public CloudScriptService(ILogger<CloudScriptService> logger, IServiceScopeFactory serviceScopeFactory, CloudScriptFunctionLoader functionLoader)
|
||||
{
|
||||
_logger = logger;
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_functionLoader = functionLoader;
|
||||
}
|
||||
|
||||
public async Task<object?> ExecuteAsync(string name, string? parameter, bool generatePlayStreamEvent)
|
||||
{
|
||||
if (!_functionLoader.TryGetFunction(name, out var function))
|
||||
{
|
||||
_logger.LogWarning("Function {Function} is missing", name);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (parameter == null)
|
||||
{
|
||||
_logger.LogWarning("Function {Function} was called without a parameter", name);
|
||||
return null;
|
||||
}
|
||||
|
||||
using (var scope = _serviceScopeFactory.CreateScope())
|
||||
{
|
||||
var functionClazz = ActivatorUtilities.CreateInstance(scope.ServiceProvider, function.Clazz);
|
||||
var functionParam = JsonSerializer.Deserialize(parameter, function.RequestType);
|
||||
if (functionParam == null)
|
||||
{
|
||||
_logger.LogWarning("Function {Function} deserialization returned null", name);
|
||||
return null;
|
||||
}
|
||||
|
||||
var functionTask = function.Delegate(functionClazz, functionParam);
|
||||
|
||||
await functionTask;
|
||||
|
||||
return (object)((dynamic)functionTask).Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Functions;
|
||||
|
||||
[CloudScriptFunction("EnterMatchmaking")]
|
||||
public class EnterMatchmaking : ICloudScriptFunction<FYEnterMatchAzureFunction, FYEnterMatchAzureFunctionResult>
|
||||
{
|
||||
public Task<FYEnterMatchAzureFunctionResult> ExecuteAsync(FYEnterMatchAzureFunction request)
|
||||
{
|
||||
return Task.FromResult(new FYEnterMatchAzureFunctionResult
|
||||
{
|
||||
Success = true,
|
||||
Address = "127.0.0.1",
|
||||
ErrorMessage = "",
|
||||
Port = 30229,
|
||||
ShardIndex = 0,
|
||||
SingleplayerStation = false,
|
||||
MaintenanceMode = false,
|
||||
SessionTimeJoinDelay = 0
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using Prospect.Server.Api.Services.Auth.Extensions;
|
||||
using Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Functions;
|
||||
|
||||
[CloudScriptFunction("GetCharacterVanity")]
|
||||
public class GetCharacterVanity : ICloudScriptFunction<FYGetCharacterVanityRequest, object?>
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public GetCharacterVanity(IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
public Task<object?> ExecuteAsync(FYGetCharacterVanityRequest request)
|
||||
{
|
||||
var context = _httpContextAccessor.HttpContext;
|
||||
if (context == null)
|
||||
{
|
||||
return Task.FromResult<object?>(null);
|
||||
}
|
||||
|
||||
return Task.FromResult<object?>(new
|
||||
{
|
||||
userId = context.User.FindAuthUserId(),
|
||||
error = (object?)null,
|
||||
returnVanity = new
|
||||
{
|
||||
userId = context.User.FindAuthUserId(),
|
||||
head_item = new
|
||||
{
|
||||
id = "Black02M_Head1",
|
||||
materialIndex = 0,
|
||||
},
|
||||
boots_item = new
|
||||
{
|
||||
id = "StarterOutfit01_Boots_M",
|
||||
materialIndex = 0,
|
||||
},
|
||||
chest_item = new
|
||||
{
|
||||
id = "StarterOutfit01_Chest_M",
|
||||
materialIndex = 0,
|
||||
},
|
||||
glove_item = new
|
||||
{
|
||||
id = "StarterOutfit01_Gloves_M",
|
||||
materialIndex = 0,
|
||||
},
|
||||
base_suit_item = new
|
||||
{
|
||||
id = "StarterOutfit01M_BaseSuit",
|
||||
materialIndex = 0,
|
||||
},
|
||||
melee_weapon_item = new
|
||||
{
|
||||
id = "Melee_Omega",
|
||||
materialIndex = 0,
|
||||
},
|
||||
body_type = 1,
|
||||
archetype_id = "TheProspector",
|
||||
slot_index = 0
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using Prospect.Server.Api.Services.Auth.Extensions;
|
||||
using Prospect.Server.Api.Services.CloudScript.Models;
|
||||
using Prospect.Server.Api.Services.CloudScript.Models.Data;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Functions;
|
||||
|
||||
[CloudScriptFunction("GetCraftingInProgressData")]
|
||||
public class GetCraftingInProgressData : ICloudScriptFunction<FYGetCraftingInProgressDataRequest, FYGetCraftingInProgressDataResult>
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public GetCraftingInProgressData(IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
public Task<FYGetCraftingInProgressDataResult> ExecuteAsync(FYGetCraftingInProgressDataRequest request)
|
||||
{
|
||||
var context = _httpContextAccessor.HttpContext;
|
||||
if (context == null)
|
||||
{
|
||||
throw new CloudScriptException("CloudScript was not called within a http request");
|
||||
}
|
||||
|
||||
return Task.FromResult(new FYGetCraftingInProgressDataResult
|
||||
{
|
||||
UserId = context.User.FindAuthUserId(),
|
||||
Error = string.Empty,
|
||||
ItemCurrentlyBeingCrafted = new FYItemCurrentlyBeingCrafted
|
||||
{
|
||||
ItemId = null,
|
||||
ItemRarity = -1,
|
||||
PurchaseAmount = -1,
|
||||
UtcTimestampWhenCraftingStarted = new FYTimestamp
|
||||
{
|
||||
Seconds = 0
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Functions;
|
||||
|
||||
[CloudScriptFunction("GetFriendList")]
|
||||
public class GetFriendList : ICloudScriptFunction<FYBaseSocialRequest, object?>
|
||||
{
|
||||
public Task<object?> ExecuteAsync(FYBaseSocialRequest request)
|
||||
{
|
||||
return Task.FromResult<object?>(new
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using Prospect.Server.Api.Services.Auth.Extensions;
|
||||
using Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Functions;
|
||||
|
||||
[CloudScriptFunction("GetPlayerSets")]
|
||||
public class GetPlayerSets : ICloudScriptFunction<FYGetPlayersSets, object?>
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public GetPlayerSets(IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
public Task<object?> ExecuteAsync(FYGetPlayersSets request)
|
||||
{
|
||||
var context = _httpContextAccessor.HttpContext;
|
||||
if (context == null)
|
||||
{
|
||||
return Task.FromResult<object?>(null);
|
||||
}
|
||||
|
||||
return Task.FromResult<object?>(new
|
||||
{
|
||||
success = true,
|
||||
entries = new []
|
||||
{
|
||||
new
|
||||
{
|
||||
setData = new
|
||||
{
|
||||
id = "",
|
||||
userId = context.User.FindAuthUserId(),
|
||||
kit = "",
|
||||
shield = "",
|
||||
helmet = "",
|
||||
weaponOne = "",
|
||||
weaponTwo = "",
|
||||
bag = "",
|
||||
bagItemsAsJsonStr = "",
|
||||
safeItemsAsJsonStr = ""
|
||||
},
|
||||
items = Array.Empty<object>()
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using Prospect.Server.Api.Services.Auth.Extensions;
|
||||
using Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Functions;
|
||||
|
||||
[CloudScriptFunction("GetPlayersInventoriesLimits")]
|
||||
public class GetPlayersInventoriesLimits : ICloudScriptFunction<FYGetPlayersInventoriesLimitsRequest, object?>
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public GetPlayersInventoriesLimits(IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
public Task<object?> ExecuteAsync(FYGetPlayersInventoriesLimitsRequest request)
|
||||
{
|
||||
var context = _httpContextAccessor.HttpContext;
|
||||
if (context == null)
|
||||
{
|
||||
return Task.FromResult<object?>(null);
|
||||
}
|
||||
|
||||
return Task.FromResult<object?>(new
|
||||
{
|
||||
success = true,
|
||||
entries = new []
|
||||
{
|
||||
new {
|
||||
userId = context.User.FindAuthUserId(),
|
||||
inventoryStashLimit = 75,
|
||||
inventoryBagLimit = 300,
|
||||
inventorySafeLimit = 5
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Functions;
|
||||
|
||||
[CloudScriptFunction("GetSignalRConnection")]
|
||||
public class GetSignalRConnection : ICloudScriptFunction<FYGetSignalRConnection, FYGetSignalRConnectionResult>
|
||||
{
|
||||
public Task<FYGetSignalRConnectionResult> ExecuteAsync(FYGetSignalRConnection request)
|
||||
{
|
||||
return Task.FromResult(new FYGetSignalRConnectionResult
|
||||
{
|
||||
Url = "https://localhost:5443/signalr/?hub=pubsub",
|
||||
AccessToken = "TEST"
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using Prospect.Server.Api.Services.Auth.Extensions;
|
||||
using Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Functions;
|
||||
|
||||
[CloudScriptFunction("RequestFactionProgression")]
|
||||
public class RequestFactionProgression : ICloudScriptFunction<FYQueryFactionProgressionRequest, object?>
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public RequestFactionProgression(IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
public Task<object?> ExecuteAsync(FYQueryFactionProgressionRequest request)
|
||||
{
|
||||
var context = _httpContextAccessor.HttpContext;
|
||||
if (context == null)
|
||||
{
|
||||
return Task.FromResult<object?>(null);
|
||||
}
|
||||
|
||||
return Task.FromResult<object?>(new
|
||||
{
|
||||
factions = new []
|
||||
{
|
||||
new
|
||||
{
|
||||
factionId = "ICA",
|
||||
currentProgression = 0
|
||||
},
|
||||
new
|
||||
{
|
||||
factionId = "Korolev",
|
||||
currentProgression = 0
|
||||
},
|
||||
new
|
||||
{
|
||||
factionId = "Osiris",
|
||||
currentProgression = 0
|
||||
},
|
||||
},
|
||||
userId = context.User.FindAuthUserId(),
|
||||
error = ""
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Functions;
|
||||
|
||||
[CloudScriptFunction("RequestMaintenanceModeState")]
|
||||
public class RequestMaintenanceModeState : ICloudScriptFunction<FYMaintenanceModeState, FYRequestMaintenanceModeStateResult>
|
||||
{
|
||||
public Task<FYRequestMaintenanceModeStateResult> ExecuteAsync(FYMaintenanceModeState request)
|
||||
{
|
||||
return Task.FromResult(new FYRequestMaintenanceModeStateResult
|
||||
{
|
||||
Enabled = false
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using Prospect.Server.Api.Services.Auth.Extensions;
|
||||
using Prospect.Server.Api.Services.CloudScript.Models;
|
||||
using Prospect.Server.Api.Services.CloudScript.Models.Data;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Functions;
|
||||
|
||||
[CloudScriptFunction("RequestPlayerContracts")]
|
||||
public class RequestPlayerContracts : ICloudScriptFunction<FYGetPlayerContractsRequest, FYGetPlayerContractsResult>
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public RequestPlayerContracts(IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
public Task<FYGetPlayerContractsResult> ExecuteAsync(FYGetPlayerContractsRequest request)
|
||||
{
|
||||
var context = _httpContextAccessor.HttpContext;
|
||||
if (context == null)
|
||||
{
|
||||
throw new CloudScriptException("CloudScript was not called within a http request");
|
||||
}
|
||||
|
||||
return Task.FromResult(new FYGetPlayerContractsResult
|
||||
{
|
||||
UserId = context.User.FindAuthUserId(),
|
||||
Error = null,
|
||||
ActiveContracts = new List<FYActiveContractPlayerData>(),
|
||||
FactionsContracts = new FYFactionsContractsData
|
||||
{
|
||||
Boards = new List<FYFactionContractsData>
|
||||
{
|
||||
new FYFactionContractsData
|
||||
{
|
||||
FactionId = "ICA",
|
||||
Contracts = new List<FYFactionContractData>
|
||||
{
|
||||
new FYFactionContractData
|
||||
{
|
||||
ContractId = "NEW-Easy-ICA-Gather-1",
|
||||
ContractIsLockedDueToLowFactionReputation = false
|
||||
},
|
||||
new FYFactionContractData
|
||||
{
|
||||
ContractId = "NEW-Medium-ICA-Uplink-1",
|
||||
ContractIsLockedDueToLowFactionReputation = false
|
||||
},
|
||||
new FYFactionContractData
|
||||
{
|
||||
ContractId = "NEW-Hard-ICA-Uplink-1",
|
||||
ContractIsLockedDueToLowFactionReputation = false
|
||||
}
|
||||
}
|
||||
},
|
||||
new FYFactionContractsData
|
||||
{
|
||||
FactionId = "Korolev",
|
||||
Contracts = new List<FYFactionContractData>
|
||||
{
|
||||
new FYFactionContractData
|
||||
{
|
||||
ContractId = "NEW-Easy-KOR-Mine-4",
|
||||
ContractIsLockedDueToLowFactionReputation = false
|
||||
},
|
||||
new FYFactionContractData
|
||||
{
|
||||
ContractId = "NEW-Medium-KOR-Mine-1",
|
||||
ContractIsLockedDueToLowFactionReputation = false
|
||||
},
|
||||
new FYFactionContractData
|
||||
{
|
||||
ContractId = "NEW-Hard-KOR-PvP-6",
|
||||
ContractIsLockedDueToLowFactionReputation = false
|
||||
}
|
||||
}
|
||||
},
|
||||
new FYFactionContractsData
|
||||
{
|
||||
FactionId = "Osiris",
|
||||
Contracts = new List<FYFactionContractData>
|
||||
{
|
||||
new FYFactionContractData
|
||||
{
|
||||
ContractId = "NEW-Easy-Osiris-Brightcaps-1",
|
||||
ContractIsLockedDueToLowFactionReputation = false
|
||||
},
|
||||
new FYFactionContractData
|
||||
{
|
||||
ContractId = "NEW-Medium-Osiris-Gather-1",
|
||||
ContractIsLockedDueToLowFactionReputation = false
|
||||
},
|
||||
new FYFactionContractData
|
||||
{
|
||||
ContractId = "NEW-Hard-Osiris-Gather-7",
|
||||
ContractIsLockedDueToLowFactionReputation = false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
LastBoardRefreshTimeUtc = new FYTimestamp
|
||||
{
|
||||
Seconds = (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds()
|
||||
}
|
||||
},
|
||||
RefreshHours24UtcFromBackend = 12
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Functions;
|
||||
|
||||
[CloudScriptFunction("SetMatchAllowJoin")]
|
||||
public class SetMatchAllowJoin : ICloudScriptFunction<FYSetAllowJoinRequest, object?>
|
||||
{
|
||||
public Task<object?> ExecuteAsync(FYSetAllowJoinRequest request)
|
||||
{
|
||||
return Task.FromResult<object?>(new
|
||||
{
|
||||
sessionId = (object?)null,
|
||||
success = false
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Functions;
|
||||
|
||||
[CloudScriptFunction("UpdatePlayerPresenceState")]
|
||||
public class UpdatePlayerPresenceState : ICloudScriptFunction<FYUpdatePlayerPresenceStateRequest, object>
|
||||
{
|
||||
public Task<object> ExecuteAsync(FYUpdatePlayerPresenceStateRequest request)
|
||||
{
|
||||
return Task.FromResult<object>(new { });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using Prospect.Server.Api.Services.Auth.Extensions;
|
||||
using Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Functions;
|
||||
|
||||
[CloudScriptFunction("UpdateRetentionBonus")]
|
||||
public class UpdateRetentionBonus : ICloudScriptFunction<FYRetentionBonusRequest, object?>
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public UpdateRetentionBonus(IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
public Task<object?> ExecuteAsync(FYRetentionBonusRequest request)
|
||||
{
|
||||
var context = _httpContextAccessor.HttpContext;
|
||||
if (context == null)
|
||||
{
|
||||
return Task.FromResult<object?>(null);
|
||||
}
|
||||
|
||||
return Task.FromResult<object?>(new
|
||||
{
|
||||
playerData = new
|
||||
{
|
||||
daysClaimed = 0,
|
||||
lastClaimTime = new
|
||||
{
|
||||
seconds = 1635033600
|
||||
}
|
||||
},
|
||||
userId = context.User.FindAuthUserId(),
|
||||
error = (object?)null
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Functions;
|
||||
|
||||
[CloudScriptFunction("VivoxLogin")]
|
||||
public class VivoxLogin : ICloudScriptFunction<FYVivoxLoginTokenRequest, FYVivoxJoinData>
|
||||
{
|
||||
public Task<FYVivoxJoinData> ExecuteAsync(FYVivoxLoginTokenRequest request)
|
||||
{
|
||||
return Task.FromResult(new FYVivoxJoinData
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Functions;
|
||||
|
||||
[CloudScriptFunction("VivoxSettings")]
|
||||
public class VivoxSettings : ICloudScriptFunction<FYEmptyRequest, FYVivoxSettingsData>
|
||||
{
|
||||
public Task<FYVivoxSettingsData> ExecuteAsync(FYEmptyRequest request)
|
||||
{
|
||||
return Task.FromResult(new FYVivoxSettingsData
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Prospect.Server.Api.Services.CloudScript;
|
||||
|
||||
public interface ICloudScriptFunction<TReq, TRes>
|
||||
{
|
||||
Task<TRes> ExecuteAsync(TReq request);
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models.Data;
|
||||
|
||||
public class FYActiveContractPlayerData
|
||||
{
|
||||
[JsonPropertyName("contractId")]
|
||||
public string ContractId { get; set; } = null!;
|
||||
|
||||
[JsonPropertyName("progress")]
|
||||
public List<int> Progress { get; set; } = null!;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models.Data;
|
||||
|
||||
public class FYFactionContractData
|
||||
{
|
||||
[JsonPropertyName("contractId")]
|
||||
public string ContractId { get; set; } = null!;
|
||||
|
||||
[JsonPropertyName("contractIsLockedDueToLowFactionReputation")]
|
||||
public bool ContractIsLockedDueToLowFactionReputation { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models.Data;
|
||||
|
||||
public class FYFactionContractsData
|
||||
{
|
||||
[JsonPropertyName("factionId")]
|
||||
public string FactionId { get; set; } = null!;
|
||||
|
||||
[JsonPropertyName("contracts")]
|
||||
public List<FYFactionContractData> Contracts { get; set; } = null!;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models.Data;
|
||||
|
||||
public class FYFactionsContractsData
|
||||
{
|
||||
[JsonPropertyName("boards")]
|
||||
public List<FYFactionContractsData> Boards { get; set; } = null!;
|
||||
|
||||
[JsonPropertyName("lastBoardRefreshTimeUtc")]
|
||||
public FYTimestamp LastBoardRefreshTimeUtc { get; set; } = null!;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models.Data;
|
||||
|
||||
public class FYItemCurrentlyBeingCrafted
|
||||
{
|
||||
[JsonPropertyName("itemId")]
|
||||
public string? ItemId { get; set; }
|
||||
|
||||
[JsonPropertyName("itemRarity")]
|
||||
public int ItemRarity { get; set; }
|
||||
|
||||
[JsonPropertyName("purchaseAmount")]
|
||||
public int PurchaseAmount { get; set; }
|
||||
|
||||
[JsonPropertyName("utcTimestampWhenCraftingStarted")]
|
||||
public FYTimestamp UtcTimestampWhenCraftingStarted { get; set; } = null!;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models.Data;
|
||||
|
||||
public class FYPurchaseInventoryInsuranceRequest
|
||||
{
|
||||
// m_insuranceId
|
||||
// m_itemIds
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models.Data;
|
||||
|
||||
public class FYTimestamp
|
||||
{
|
||||
[JsonPropertyName("seconds")]
|
||||
public int Seconds { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models.Data;
|
||||
|
||||
public class FYVivoxJoinTokenRequest
|
||||
{
|
||||
[JsonPropertyName("userName")]
|
||||
public string? Username { get; set; }
|
||||
|
||||
[JsonPropertyName("channel")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Channel { get; set; }
|
||||
|
||||
// TODO: channelType
|
||||
// TODO: hasText
|
||||
// TODO: hasAudio
|
||||
// TODO: channelId
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYBaseSocialRequest
|
||||
{
|
||||
[JsonPropertyName("targetPlayFabId")]
|
||||
public string? TargetPlayFabId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYEmptyRequest
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Prospect.Server.Api.Services.CloudScript.Models.Data;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYEnterMatchAzureFunction
|
||||
{
|
||||
[JsonPropertyName("optimalRegion")]
|
||||
public string? OptimalRegion { get; set; }
|
||||
|
||||
[JsonPropertyName("isMatch")]
|
||||
public bool IsMatch { get; set; }
|
||||
|
||||
[JsonPropertyName("bypassMaintenanceMode")]
|
||||
public bool BypassMaintenanceMode { get; set; }
|
||||
|
||||
[JsonPropertyName("debugOption")]
|
||||
public string? DebugOption { get; set; }
|
||||
|
||||
[JsonPropertyName("mapName")]
|
||||
public string? MapName { get; set; }
|
||||
|
||||
[JsonPropertyName("squad_id")]
|
||||
public string? SquadId { get; set; }
|
||||
|
||||
[JsonPropertyName("purchaseInventoryInsurances")]
|
||||
public List<FYPurchaseInventoryInsuranceRequest>? PurchaseInventoryInsurances { get; set; }
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYEnterMatchAzureFunctionResult
|
||||
{
|
||||
[JsonPropertyName("success")]
|
||||
public bool Success { get; set; }
|
||||
|
||||
[JsonPropertyName("address")]
|
||||
public string? Address { get; set; }
|
||||
|
||||
[JsonPropertyName("errorMessage")]
|
||||
public string? ErrorMessage { get; set; }
|
||||
|
||||
[JsonPropertyName("port")]
|
||||
public int Port { get; set; }
|
||||
|
||||
[JsonPropertyName("sharedIndex")]
|
||||
public int ShardIndex { get; set; }
|
||||
|
||||
[JsonPropertyName("singleplayerStation")]
|
||||
public bool SingleplayerStation { get; set; }
|
||||
|
||||
[JsonPropertyName("maintenanceMode")]
|
||||
public bool MaintenanceMode { get; set; }
|
||||
|
||||
[JsonPropertyName("sessionTimeJoinDelay")]
|
||||
public float SessionTimeJoinDelay { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYGetCharacterVanityRequest
|
||||
{
|
||||
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYGetCraftingInProgressDataRequest
|
||||
{
|
||||
[JsonPropertyName("userId")]
|
||||
public string? UserId { get; set; }
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Prospect.Server.Api.Services.CloudScript.Models.Data;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYGetCraftingInProgressDataResult
|
||||
{
|
||||
[JsonPropertyName("userId")]
|
||||
public string UserId { get; set; } = null!;
|
||||
|
||||
[JsonPropertyName("error")]
|
||||
public string Error { get; set; } = null!;
|
||||
|
||||
[JsonPropertyName("itemCurrentlyBeingCrafted")]
|
||||
public FYItemCurrentlyBeingCrafted ItemCurrentlyBeingCrafted { get; set; } = null!;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYGetPlayerContractsRequest
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Prospect.Server.Api.Services.CloudScript.Models.Data;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYGetPlayerContractsResult
|
||||
{
|
||||
[JsonPropertyName("userId")]
|
||||
public string UserId { get; set; } = null!;
|
||||
|
||||
[JsonPropertyName("error")]
|
||||
public string? Error { get; set; }
|
||||
|
||||
[JsonPropertyName("activeContracts")]
|
||||
public List<FYActiveContractPlayerData> ActiveContracts { get; set; } = null!;
|
||||
|
||||
[JsonPropertyName("factionsContracts")]
|
||||
public FYFactionsContractsData FactionsContracts { get; set; } = null!;
|
||||
|
||||
[JsonPropertyName("refreshHours24UtcFromBackend")]
|
||||
public int RefreshHours24UtcFromBackend { get; set; }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYGetPlayersInventoriesLimitsRequest
|
||||
{
|
||||
[JsonPropertyName("userIds")]
|
||||
public List<string>? UserIds { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYGetPlayersSets
|
||||
{
|
||||
[JsonPropertyName("userIds")]
|
||||
public List<string>? UserIds { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYGetSignalRConnection
|
||||
{
|
||||
[JsonPropertyName("userId")]
|
||||
public string UserId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYGetSignalRConnectionResult
|
||||
{
|
||||
[JsonPropertyName("url")]
|
||||
public string Url { get; set; } = null!;
|
||||
|
||||
[JsonPropertyName("accessToken")]
|
||||
public string AccessToken { get; set; } = null!;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYMaintenanceModeState
|
||||
{
|
||||
[JsonPropertyName("bypassMaintenanceMode")]
|
||||
public bool BypassMaintenanceMode { get; set; }
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYQueryFactionProgressionRequest
|
||||
{
|
||||
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYRequestMaintenanceModeStateResult
|
||||
{
|
||||
[JsonPropertyName("enabled")]
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYRetentionBonusRequest
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYSetAllowJoinRequest
|
||||
{
|
||||
[JsonPropertyName("sessionId")]
|
||||
public string? SessionId { get; set; }
|
||||
|
||||
[JsonPropertyName("allowJoin")]
|
||||
public bool AllowJoin { get; set; }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYUpdatePlayerPresenceStateRequest
|
||||
{
|
||||
[JsonPropertyName("inMatch")]
|
||||
public bool InMatch { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Prospect.Server.Api.Services.CloudScript.Models.Data;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYVivoxJoinData
|
||||
{
|
||||
[JsonPropertyName("request")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public FYVivoxJoinTokenRequest? Request { get; set; }
|
||||
|
||||
[JsonPropertyName("token")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Token { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYVivoxLoginTokenRequest
|
||||
{
|
||||
[JsonPropertyName("username")]
|
||||
public string? Username { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Prospect.Server.Api.Services.CloudScript.Models;
|
||||
|
||||
public class FYVivoxSettingsData
|
||||
{
|
||||
[JsonPropertyName("vivoxServer")]
|
||||
public string? VivoxServer { get; set; }
|
||||
|
||||
[JsonPropertyName("vivoxDomain")]
|
||||
public string? VivoxDomain { get; set; }
|
||||
|
||||
[JsonPropertyName("vivoxIssuer")]
|
||||
public string? VivoxIssuer { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user