PalacePal/Pal.Client/Database/RemoteEncounter.cs

41 lines
1.3 KiB
C#
Raw Normal View History

2023-02-17 17:36:22 +00:00
using System.ComponentModel.DataAnnotations;
using Pal.Client.Extensions;
using Pal.Client.Net;
2023-03-30 20:01:43 +00:00
namespace Pal.Client.Database;
/// <summary>
/// To avoid sending too many requests to the server, we cache which locations have been seen
/// locally. These never expire, and locations which have been seen with a specific account
/// are never sent to the server again.
///
/// To be marked as seen, it needs to be essentially processed by <see cref="RemoteApi.MarkAsSeen"/>.
/// </summary>
internal sealed class RemoteEncounter
2023-02-17 17:36:22 +00:00
{
2023-03-30 20:01:43 +00:00
[Key]
public int Id { get; private set; }
2023-02-17 17:36:22 +00:00
2023-03-30 20:01:43 +00:00
public int ClientLocationId { get; private set; }
public ClientLocation ClientLocation { get; private set; } = null!;
2023-02-17 17:36:22 +00:00
2023-03-30 20:01:43 +00:00
/// <summary>
/// Partial account id. This is partially unique - however problems would (in theory)
/// only occur once you have two account-ids where the first 13 characters are equal.
/// </summary>
[MaxLength(13)]
public string AccountId { get; private set; }
2023-02-17 17:36:22 +00:00
2023-03-30 20:01:43 +00:00
private RemoteEncounter(int clientLocationId, string accountId)
{
ClientLocationId = clientLocationId;
AccountId = accountId;
}
2023-02-17 17:36:22 +00:00
2023-03-30 20:01:43 +00:00
public RemoteEncounter(ClientLocation clientLocation, string accountId)
{
ClientLocation = clientLocation;
AccountId = accountId.ToPartialId();
2023-02-17 17:36:22 +00:00
}
}