v6: Replace palace.proto/export.proto with net model

This commit is contained in:
Liza 2023-12-15 02:26:50 +01:00
parent 4ded313998
commit 375c99e313
Signed by: liza
GPG Key ID: 7199F8D727D55F67
29 changed files with 179 additions and 140 deletions

View File

@ -73,6 +73,11 @@
"resolved": "2.14.1",
"contentHash": "lQKvtaTDOXnoVJ20ibTuSIOf2i0uO0MPbDhd1jm238I+U/2ZnRENj0cktKZhtchBMtCUSRQ5v4xBCUbKNmyVMw=="
},
"MessagePack.Annotations": {
"type": "Transitive",
"resolved": "2.5.140",
"contentHash": "JE3vwluOrsJ4t3hnfXzIxJUh6lhx6M/KR8Sark/HOUw1DJ5UKu5JsAnnuaQngg6poFkRx1lzHSLTkxHNJO7+uQ=="
},
"Microsoft.Data.Sqlite.Core": {
"type": "Transitive",
"resolved": "7.0.13",
@ -273,7 +278,10 @@
"type": "Project"
},
"pal.common": {
"type": "Project"
"type": "Project",
"dependencies": {
"MessagePack.Annotations": "[2.5.140, )"
}
}
},
"net7.0-windows7.0/win-x64": {

View File

@ -1,4 +1,4 @@
namespace Pal.Common.Net.Models;
namespace Pal.Common.Net.Models.Account;
public sealed class CreateAccountError
{

View File

@ -1,4 +1,4 @@
namespace Pal.Common.Net.Models;
namespace Pal.Common.Net.Models.Account;
public sealed class CreateAccountReply
{

View File

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Pal.Common.Net.Models;
namespace Pal.Common.Net.Models.Account;
public sealed class CreateAccountRequest
{

View File

@ -1,4 +1,4 @@
namespace Pal.Common.Net.Models;
namespace Pal.Common.Net.Models.Account;
public sealed class LoginError
{

View File

@ -1,4 +1,4 @@
namespace Pal.Common.Net.Models;
namespace Pal.Common.Net.Models.Account;
public sealed class LoginReply
{

View File

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Pal.Common.Net.Models;
namespace Pal.Common.Net.Models.Account;
public sealed class LoginRequest
{

View File

@ -1,4 +1,4 @@
namespace Pal.Common.Net.Models;
namespace Pal.Common.Net.Models.Account;
public sealed class Version
{

View File

@ -0,0 +1,13 @@
using MessagePack;
namespace Pal.Common.Net.Models.Export;
[MessagePackObject]
public sealed class ExportFloor
{
[Key(0)]
public required ETerritoryType TerritoryType { get; init; }
[Key(1)]
public required List<ExportObject> Objects { get; init; }
}

View File

@ -0,0 +1,20 @@
using MessagePack;
using Pal.Common.Net.Models.Palace;
namespace Pal.Common.Net.Models.Export;
[MessagePackObject]
public sealed class ExportObject
{
[Key(0)]
public required EObjectType Type { get; init; }
[Key(1)]
public required float X { get; set; }
[Key(2)]
public required float Y { get; set; }
[Key(3)]
public required float Z { get; set; }
}

View File

@ -0,0 +1,6 @@
namespace Pal.Common.Net.Models.Export;
public sealed class ExportRequest
{
public required string ServerUrl { get; init; }
}

View File

@ -0,0 +1,22 @@
using MessagePack;
namespace Pal.Common.Net.Models.Export;
[MessagePackObject]
public sealed class ExportRoot
{
[Key(0)]
public required Guid ExportId { get; init; }
[Key(1)]
public required int ExportVersion { get; init; }
[Key(2)]
public required string ServerUrl { get; init; }
[Key(3)]
public required DateTime CreatedAt { get; init; }
[Key(4)]
public required List<ExportFloor> Floors { get; init; }
}

View File

@ -0,0 +1,6 @@
namespace Pal.Common.Net.Models.Palace;
public sealed class DownloadFloorsError
{
}

View File

@ -0,0 +1,7 @@

namespace Pal.Common.Net.Models.Palace;
public sealed class DownloadFloorsReply
{
public required List<PalaceObject> Objects { get; init; }
}

View File

@ -0,0 +1,10 @@
namespace Pal.Common.Net.Models.Palace;
public enum EObjectType : int
{
Unknown = 0,
Trap = 1,
Hoard = 2,
Debug_NotSynchronized = 3,
}

View File

@ -0,0 +1,6 @@

namespace Pal.Common.Net.Models.Palace;
public sealed class MarkObjectsSeenError
{
}

View File

@ -0,0 +1,5 @@
namespace Pal.Common.Net.Models.Palace;
public sealed class MarkObjectsSeenReply
{
}

View File

@ -0,0 +1,7 @@
namespace Pal.Common.Net.Models.Palace;
public sealed class MarkObjectsSeenRequest
{
public required ETerritoryType TerritoryType { get; init; }
public required List<Guid> NetworkIds { get; init; }
}

View File

@ -0,0 +1,12 @@
namespace Pal.Common.Net.Models.Palace;
public sealed class PalaceObject
{
public required EObjectType Type { get; init; }
public required float X { get; init; }
public required float Y { get; init; }
public required float Z { get; init; }
public Guid NetworkId { get; init; }
}

View File

@ -0,0 +1,5 @@
namespace Pal.Common.Net.Models.Palace;
public sealed class StatisticsError
{
}

View File

@ -0,0 +1,13 @@
namespace Pal.Common.Net.Models.Palace;
public sealed class StatisticsReply
{
public required List<FloorStatistics> Floors { get; init; }
public sealed class FloorStatistics
{
public required ETerritoryType TerritoryType { get; init; }
public required uint TrapCount { get; init; }
public required uint HoardCount { get; init; }
}
}

View File

@ -0,0 +1,5 @@
namespace Pal.Common.Net.Models.Palace;
public sealed class UploadFloorsError
{
}

View File

@ -0,0 +1,6 @@
namespace Pal.Common.Net.Models.Palace;
public sealed class UploadFloorsReply
{
public required List<PalaceObject> Objects { get; init; }
}

View File

@ -0,0 +1,7 @@
namespace Pal.Common.Net.Models.Palace;
public sealed class UploadFloorsRequest
{
public required ETerritoryType TerritoryType { get; init; }
public required List<PalaceObject> Objects { get; init; }
}

View File

@ -9,4 +9,8 @@
<PathMap Condition="$(SolutionDir) != ''">$(SolutionDir)=X:\</PathMap>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MessagePack.Annotations" Version="2.5.140" />
</ItemGroup>
</Project>

View File

@ -1,58 +0,0 @@
syntax = "proto3";
package export;
import "google/protobuf/timestamp.proto";
service ExportService {
rpc Export(ExportRequest) returns (ExportReply);
}
message ExportRequest {
string serverUrl = 1;
}
message ExportReply {
bool success = 1;
ExportRoot data = 2;
ExportError error = 3;
}
enum ExportError {
EXPORT_ERROR_NONE = 0;
EXPORT_ERROR_UNKNOWN = 1;
}
message ExportRoot {
string exportId = 1;
// Only increases if the export format changes, in case of backwards-incompatible changes.
int32 exportVersion = 2;
string serverUrl = 3;
// Server MAY decide not to send any markers older than this.
google.protobuf.Timestamp createdAt = 4;
repeated ExportFloor floors = 5;
}
message ExportFloor {
uint32 territoryType = 1;
repeated ExportObject objects = 2;
}
message ExportObject {
ExportObjectType type = 1;
float x = 2;
float y = 3;
float z = 4;
//string networkId = 5;
}
enum ExportObjectType {
EXPORT_OBJECT_TYPE_UNKNOWN = 0;
EXPORT_OBJECT_TYPE_TRAP = 1;
EXPORT_OBJECT_TYPE_HOARD = 2;
}

View File

@ -1,72 +0,0 @@
syntax = "proto3";
package palace;
service PalaceService {
rpc DownloadFloors(DownloadFloorsRequest) returns (DownloadFloorsReply);
rpc UploadFloors(UploadFloorsRequest) returns (UploadFloorsReply);
rpc MarkObjectsSeen(MarkObjectsSeenRequest) returns (MarkObjectsSeenReply);
rpc FetchStatistics(StatisticsRequest) returns (StatisticsReply);
}
message DownloadFloorsRequest {
uint32 territoryType = 1;
}
message DownloadFloorsReply {
bool success = 1;
repeated PalaceObject objects = 2;
}
message UploadFloorsRequest {
uint32 territoryType = 1;
repeated PalaceObject objects = 2;
}
message UploadFloorsReply {
bool success = 1;
repeated PalaceObject objects = 2;
}
message StatisticsRequest {
}
message StatisticsReply {
bool success = 1;
repeated FloorStatistics floorStatistics = 2;
}
message FloorStatistics {
uint32 territoryType = 1;
uint32 trapCount = 2;
uint32 hoardCount = 3;
}
message PalaceObject {
ObjectType type = 1;
float x = 2;
float y = 3;
float z = 4;
// Ignored for uploaded markers.
string networkId = 5;
}
message MarkObjectsSeenRequest {
uint32 territoryType = 1;
repeated string networkIds = 2;
}
message MarkObjectsSeenReply {
bool success = 1;
}
enum ObjectType {
OBJECT_TYPE_UNKNOWN = 0;
OBJECT_TYPE_TRAP = 1;
OBJECT_TYPE_HOARD = 2;
// Objects only really used for debugging, may not return any objects at any point in time.
// Semi-Permanent: Not saved locally, but saved on the server.
reserved 3;
}

View File

@ -1,6 +1,13 @@
{
"version": 1,
"dependencies": {
"net7.0": {}
"net7.0": {
"MessagePack.Annotations": {
"type": "Direct",
"requested": "[2.5.140, )",
"resolved": "2.5.140",
"contentHash": "JE3vwluOrsJ4t3hnfXzIxJUh6lhx6M/KR8Sark/HOUw1DJ5UKu5JsAnnuaQngg6poFkRx1lzHSLTkxHNJO7+uQ=="
}
}
}
}

2
Server

@ -1 +1 @@
Subproject commit ad12f4fa2b89fbdd8bab4c10e379a6557c644873
Subproject commit 7b0513278b97a7a45113ef33c74e84e92fedf900