-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathRomMSyncModels.cs
More file actions
114 lines (87 loc) · 3.3 KB
/
Copy pathRomMSyncModels.cs
File metadata and controls
114 lines (87 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace RomM.Models.RomM.Save
{
/// <summary>
/// A single locally-known save reported to POST /sync/negotiate. The server keys saves by
/// (rom_id, slot) and compares <see cref="ContentHash"/> (MD5 hex) then <see cref="UpdatedAt"/>
/// against its own copy to decide the sync action.
/// </summary>
public class RomMClientSaveState
{
[JsonProperty("rom_id")]
public int RomId { get; set; }
[JsonProperty("file_name")]
public string FileName { get; set; }
[JsonProperty("slot")]
public string Slot { get; set; }
[JsonProperty("emulator")]
public string Emulator { get; set; }
[JsonProperty("content_hash")]
public string ContentHash { get; set; }
[JsonProperty("updated_at")]
public DateTime UpdatedAt { get; set; }
[JsonProperty("file_size_bytes")]
public long FileSizeBytes { get; set; }
}
public class RomMSyncNegotiatePayload
{
[JsonProperty("device_id")]
public string DeviceId { get; set; }
[JsonProperty("saves")]
public List<RomMClientSaveState> Saves { get; set; } = new List<RomMClientSaveState>();
}
/// <summary>The action the server wants the client to perform for a given save.</summary>
public static class RomMSyncAction
{
public const string Upload = "upload";
public const string Download = "download";
public const string Conflict = "conflict";
public const string NoOp = "no_op";
}
public class RomMSyncOperation
{
[JsonProperty("action")]
public string Action { get; set; }
[JsonProperty("rom_id")]
public int RomId { get; set; }
[JsonProperty("save_id")]
public int? SaveId { get; set; }
[JsonProperty("file_name")]
public string FileName { get; set; }
[JsonProperty("slot")]
public string Slot { get; set; }
[JsonProperty("emulator")]
public string Emulator { get; set; }
[JsonProperty("reason")]
public string Reason { get; set; }
[JsonProperty("server_updated_at")]
public DateTime? ServerUpdatedAt { get; set; }
[JsonProperty("server_content_hash")]
public string ServerContentHash { get; set; }
}
public class RomMSyncNegotiateResponse
{
[JsonProperty("session_id")]
public int SessionId { get; set; }
[JsonProperty("operations")]
public List<RomMSyncOperation> Operations { get; set; } = new List<RomMSyncOperation>();
[JsonProperty("total_upload")]
public int TotalUpload { get; set; }
[JsonProperty("total_download")]
public int TotalDownload { get; set; }
[JsonProperty("total_conflict")]
public int TotalConflict { get; set; }
[JsonProperty("total_no_op")]
public int TotalNoOp { get; set; }
}
/// <summary>Payload for POST /sync/sessions/{id}/complete. play_sessions is omitted (null).</summary>
public class RomMSyncCompletePayload
{
[JsonProperty("operations_completed")]
public int OperationsCompleted { get; set; }
[JsonProperty("operations_failed")]
public int OperationsFailed { get; set; }
}
}