namespace RecRoomArchive.Services
{
///
/// Used to get the appVersion from the client to determine how to run the server
///
public class AppVersionService
{
///
/// AppVersion reference
///
private static string? AppVersion { get; set; }
///
/// The AppVersion as it would want to be seen by the game
///
private static string? FullAppVersion { get; set; }
///
/// The BuildTimestamp of the build, this is a long that when converted to ticks, will be the accurate time at which the game was built.
/// This only exists on some builds so I wouldn't rely on it too much
///
private static DateTime? BuildTimestamp { get; set; }
///
/// The BuildTimestamp as it would want to be seen by the game
///
private static long? FullBuildTimestamp { get; set; }
///
/// To store the AppVersion of the current build
///
/// The version of the game
/// If the operation was a success
public async Task StoreAppVersion(string appVersion)
{
if (appVersion == null)
return false;
// To remove any _EA's or .01's or just any weird Rec Room bullshit from the build's name
var standardizedAppVersion = await ParseAppVersion(appVersion);
// idrk if storing both of these is overkill
FullAppVersion = appVersion;
AppVersion = standardizedAppVersion;
Console.WriteLine($"appVersion: {FullAppVersion}, standardizedAppVersion: {AppVersion}");
return true;
}
///
/// To store the BuildTimestamp of the current build
///
/// The BuildTimestamp of the game
/// If the operation was a success
public async Task StoreBuildTimestamp(long buildTimestamp)
{
if (buildTimestamp == 0)
return false;
DateTime buildTimestampDateTime = new(buildTimestamp);
// same here
FullBuildTimestamp = buildTimestamp;
BuildTimestamp = buildTimestampDateTime;
Console.WriteLine($"buildTimestamp: {FullBuildTimestamp}, buildTimestampDateTime: {BuildTimestamp}");
return true;
}
///
/// Parses the appVersion to "remove any _EA's or .01's or just any weird Rec Room bullshit from the build's name"
///
/// The version of the game
/// The standardized string of the appVersion
public async Task ParseAppVersion(string appVersion)
{
// To remove any _EA's or .01's or just any weird Rec Room bullshit from the build's name
int index = appVersion.IndexOfAny(['_', '.']);
string standardizedAppVersion = index >= 0 ? appVersion[..index] : appVersion;
return standardizedAppVersion;
}
}
}