Skip to content

Commit 6bb7bdb

Browse files
authored
Merge pull request #907 from PlayEveryWare/fix/manager-to-service-rename
fix: Rename managers that have been refactored into services
2 parents c2bfef6 + 62eb07d commit 6bb7bdb

File tree

11 files changed

+113
-94
lines changed

11 files changed

+113
-94
lines changed

Assets/Scripts/EOSTransferInProgress.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace PlayEveryWare.EpicOnlineServices.Samples
2727
using Utility;
2828

2929
/// <summary>
30-
/// Class <c>EOSTransferInProgress</c> is used in <c>EOSTitleStorageManager</c> and <c>EOSPlayerDataStorageManager</c> to keep track of downloaded cached file data.
30+
/// Class <c>EOSTransferInProgress</c> is used in <c>EOSTitleStorageManager</c> and <c>PlayerDataStorageService</c> to keep track of downloaded cached file data.
3131
/// </summary>
3232
public class EOSTransferInProgress
3333
{

Assets/Scripts/StandardSamples/Services/EOSService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ namespace PlayEveryWare.EpicOnlineServices
2525
{
2626
using Epic.OnlineServices;
2727
using System;
28-
using System.Runtime.CompilerServices;
2928
using System.Threading.Tasks;
3029

3130
/// <summary>
3231
/// Contains implementation of common functionality between different
3332
/// EOS Service managers (Currently AchievementsService and StatsService).
3433
/// </summary>
35-
public abstract class EOSService : IEOSSubManager, IDisposable
34+
public abstract class EOSService : IDisposable
3635
{
3736
/// <summary>
3837
/// Describes the function signature for the event that triggers when
@@ -174,8 +173,9 @@ private void OnAuthenticationChanged(bool authenticated)
174173

175174
/// <summary>
176175
/// Implement this method to perform tasks when a user authenticates.
176+
/// By default, there is no action taken.
177177
/// </summary>
178-
protected abstract void OnLoggedIn();
178+
protected virtual void OnLoggedIn() { }
179179

180180
/// <summary>
181181
/// If there are tasks that need to be done when logged out, consider

Assets/Scripts/EOSPlayerDataStorageManager.cs renamed to Assets/Scripts/StandardSamples/Services/PlayerDataStorageService.cs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,41 @@ namespace PlayEveryWare.EpicOnlineServices.Samples
2929
using Epic.OnlineServices;
3030
using Epic.OnlineServices.PlayerDataStorage;
3131

32-
/// <summary>Class <c>EOSPlayerDataStorageManager</c> is a simplified wrapper for EOS [PlayerDataStorage Interface](https://dev.epicgames.com/docs/services/en-US/Interfaces/PlayerDataStorage/index.html).</summary>
33-
public class EOSPlayerDataStorageManager : DataService<PlayerDataStorageFileTransferRequestWrapper>
32+
/// <summary>Class <c>PlayerDataStorageService</c> is a simplified wrapper for EOS [PlayerDataStorage Interface](https://dev.epicgames.com/docs/services/en-US/Interfaces/PlayerDataStorage/index.html).</summary>
33+
public class PlayerDataStorageService
34+
35+
: StorageService<PlayerDataStorageFileTransferRequestWrapper>
3436
{
3537
public event Action OnFileListUpdated;
3638

39+
#region Singleton Implementation
40+
41+
/// <summary>
42+
/// Lazy instance for singleton allows for thread-safe interactions with
43+
/// the TitleStorageService
44+
/// </summary>
45+
private static readonly Lazy<PlayerDataStorageService> s_LazyInstance = new(() => new PlayerDataStorageService());
46+
47+
/// <summary>
48+
/// Accessor for the instance.
49+
/// </summary>
50+
public static PlayerDataStorageService Instance
51+
{
52+
get
53+
{
54+
return s_LazyInstance.Value;
55+
}
56+
}
57+
58+
/// <summary>
59+
/// Private constructor guarantees adherence to thread-safe singleton
60+
/// pattern.
61+
/// </summary>
62+
private PlayerDataStorageService() { }
63+
64+
#endregion
65+
66+
3767
//-------------------------------------------------------------------------
3868
/// <summary>(async) Query list of files.</summary>
3969
public void QueryFileList()

Assets/Scripts/EOSPlayerDataStorageManager.cs.meta renamed to Assets/Scripts/StandardSamples/Services/PlayerDataStorageService.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/StandardSamples/Services/DataService.cs renamed to Assets/Scripts/StandardSamples/Services/StorageService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace PlayEveryWare.EpicOnlineServices
3737
/// <typeparam name="T">
3838
/// The type of file transfer request that this data service makes use of.
3939
/// </typeparam>
40-
public abstract class DataService<T> : EOSService where T : IFileTransferRequest
40+
public abstract class StorageService<T> : EOSService where T : IFileTransferRequest
4141
{
4242
/// <summary>
4343
/// Reference to an instance of a transfer request created within the

Assets/Scripts/StandardSamples/Services/DataService.cs.meta renamed to Assets/Scripts/StandardSamples/Services/StorageService.cs.meta

File renamed without changes.

Assets/Scripts/EOSTitleStorageManager.cs renamed to Assets/Scripts/StandardSamples/Services/TitleStorageService.cs

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,39 @@ namespace PlayEveryWare.EpicOnlineServices.Samples
2929
using UnityEngine;
3030
using Epic.OnlineServices;
3131
using Epic.OnlineServices.TitleStorage;
32-
33-
/// <summary>Class <c>EOSTitleStorageManager</c> is a simplified wrapper for EOS [TitleStorage Interface](https://dev.epicgames.com/docs/services/en-US/Interfaces/TitleStorage/index.html).</summary>
34-
public class EOSTitleStorageManager : DataService<TitleStorageFileTransferRequestWrapper>
32+
33+
/// <summary>Class <c>TitleStorageService</c> is a simplified wrapper for EOS [TitleStorage Interface](https://dev.epicgames.com/docs/services/en-US/Interfaces/TitleStorage/index.html).</summary>
34+
public class TitleStorageService : StorageService<TitleStorageFileTransferRequestWrapper>
3535
{
3636
private List<string> CurrentFileNames = new List<string>();
3737

38+
#region Singleton Implementation
39+
40+
/// <summary>
41+
/// Lazy instance for singleton allows for thread-safe interactions with
42+
/// the TitleStorageService
43+
/// </summary>
44+
private static readonly Lazy<TitleStorageService> s_LazyInstance = new(() => new TitleStorageService());
45+
46+
/// <summary>
47+
/// Accessor for the instance.
48+
/// </summary>
49+
public static TitleStorageService Instance
50+
{
51+
get
52+
{
53+
return s_LazyInstance.Value;
54+
}
55+
}
56+
57+
/// <summary>
58+
/// Private constructor guarantees adherence to thread-safe singleton
59+
/// pattern.
60+
/// </summary>
61+
private TitleStorageService() { }
62+
63+
#endregion
64+
3865
// Manager Callbacks
3966
public EOSResultEventHandler QueryListCallback { get; private set; } = null;
4067

@@ -43,14 +70,6 @@ public List<string> GetCachedCurrentFileNames()
4370
return CurrentFileNames;
4471
}
4572

46-
/// <summary>User Logged In actions</summary>
47-
/// <list type="bullet">
48-
/// <item><description><c>NA</c></description></item>
49-
/// </list>
50-
protected override void OnLoggedIn()
51-
{
52-
}
53-
5473
protected override Task InternalRefreshAsync()
5574
{
5675
// TODO: Needs implementation

Assets/Scripts/EOSTitleStorageManager.cs.meta renamed to Assets/Scripts/StandardSamples/Services/TitleStorageService.cs.meta

File renamed without changes.

Assets/Scripts/StandardSamples/UI/Storage/Player/UIPlayerDataStorageMenu.cs

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public class UIPlayerDataStorageMenu : SampleMenu
6161

6262
private string currentSelectedFile = string.Empty;
6363

64-
private EOSPlayerDataStorageManager PlayerDataStorageManager;
6564
private PlayerDataInventory currentInventory = null;
6665

6766
private HashSet<string> fileNames = new();
@@ -70,31 +69,19 @@ public class UIPlayerDataStorageMenu : SampleMenu
7069
protected override void Awake()
7170
{
7271
base.Awake();
73-
PlayerDataStorageManager = EOSManager.Instance.GetOrCreateManager<EOSPlayerDataStorageManager>();
7472
fileNameUIEntries.AddRange(FilesContentParent.GetComponentsInChildren<UIFileNameEntry>(true));
7573
}
7674

77-
protected override void OnEnable()
78-
{
79-
base.OnEnable();
80-
}
81-
8275
private void Start()
8376
{
8477
RemoteViewText.text = string.Empty;
8578
LocalViewText.text = string.Empty;
8679
CurrentFileNameText.text = "*No File Selected*";
8780
}
8881

89-
protected override void OnDestroy()
90-
{
91-
base.OnDestroy();
92-
EOSManager.Instance.RemoveManager<EOSPlayerDataStorageManager>();
93-
}
94-
9582
private void UpdateFileListUI()
9683
{
97-
if (PlayerDataStorageManager.GetLocallyCachedData().Count != fileNameUIEntries.Count)
84+
if (PlayerDataStorageService.Instance.GetLocallyCachedData().Count != fileNameUIEntries.Count)
9885
{
9986
// Destroy current UI member list
10087
foreach (var entry in fileNameUIEntries)
@@ -104,7 +91,7 @@ private void UpdateFileListUI()
10491
fileNameUIEntries.Clear();
10592
fileNames.Clear();
10693

107-
foreach (string fileName in PlayerDataStorageManager.GetLocallyCachedData().Keys)
94+
foreach (string fileName in PlayerDataStorageService.Instance.GetLocallyCachedData().Keys)
10895
{
10996
fileNames.Add(fileName);
11097
GameObject fileUIObj = Instantiate(UIFileNameEntryPrefab, FilesContentParent.transform);
@@ -128,13 +115,13 @@ private void UpdateFileListUI()
128115

129116
public void RefreshButtonOnClick()
130117
{
131-
PlayerDataStorageManager.GetLocallyCachedData().Clear();
118+
PlayerDataStorageService.Instance.GetLocallyCachedData().Clear();
132119

133-
PlayerDataStorageManager.QueryFileList();
120+
PlayerDataStorageService.Instance.QueryFileList();
134121

135122
if (currentSelectedFile != string.Empty)
136123
{
137-
PlayerDataStorageManager.DownloadFile(currentSelectedFile, () => UpdateRemoteView(currentSelectedFile));
124+
PlayerDataStorageService.Instance.DownloadFile(currentSelectedFile, () => UpdateRemoteView(currentSelectedFile));
138125
}
139126
}
140127

@@ -153,7 +140,7 @@ public void NewFileButtonOnClick()
153140
// Un-comment the following lines to test a large file
154141
// newFileContents = new string('*', 20000);
155142

156-
PlayerDataStorageManager.AddFile(NewFileNameTextBox.InputField.text, newFileContents, UpdateFileListUI);
143+
PlayerDataStorageService.Instance.AddFile(NewFileNameTextBox.InputField.text, newFileContents, UpdateFileListUI);
157144

158145
NewFileNameTextBox.InputField.text = string.Empty;
159146
}
@@ -172,7 +159,7 @@ public void SaveButtonOnClick()
172159
return;
173160
}
174161

175-
PlayerDataStorageManager.AddFile(currentSelectedFile, LocalViewText.text, () => UpdateRemoteView(currentSelectedFile));
162+
PlayerDataStorageService.Instance.AddFile(currentSelectedFile, LocalViewText.text, () => UpdateRemoteView(currentSelectedFile));
176163
}
177164

178165
public void DownloadButtonOnClick()
@@ -220,7 +207,7 @@ public void DuplicateButtonOnClick()
220207
copyName = copyName + copyIndex;
221208
}
222209

223-
PlayerDataStorageManager.CopyFile(currentSelectedFile, copyName);
210+
PlayerDataStorageService.Instance.CopyFile(currentSelectedFile, copyName);
224211
}
225212

226213
public void DeleteButtonOnClick()
@@ -231,7 +218,7 @@ public void DeleteButtonOnClick()
231218
return;
232219
}
233220

234-
PlayerDataStorageManager.DeleteFile(currentSelectedFile);
221+
PlayerDataStorageService.Instance.DeleteFile(currentSelectedFile);
235222

236223
currentSelectedFile = string.Empty;
237224
CurrentFileNameText.text = "*No File Selected*";
@@ -257,12 +244,12 @@ private void FileListOnClick(string fileName)
257244

258245
private void UpdateRemoteView(string fileName)
259246
{
260-
string fileContent = PlayerDataStorageManager.GetCachedFileContent(fileName);
247+
string fileContent = PlayerDataStorageService.Instance.GetCachedFileContent(fileName);
261248

262249
if (fileContent == null)
263250
{
264251
RemoteViewText.text = "*** Downloading content ***";
265-
PlayerDataStorageManager.DownloadFile(fileName, () => UpdateRemoteView(fileName));
252+
PlayerDataStorageService.Instance.DownloadFile(fileName, () => UpdateRemoteView(fileName));
266253
}
267254
else if (fileContent.Length == 0)
268255
{
@@ -306,18 +293,13 @@ public override void Show()
306293
{
307294
base.Show();
308295
UpdateFileListUI();
309-
PlayerDataStorageManager.OnFileListUpdated += UpdateFileListUI;
296+
PlayerDataStorageService.Instance.OnFileListUpdated += UpdateFileListUI;
310297
}
311298

312299
public override void Hide()
313300
{
314301
base.Hide();
315302

316-
if (null != PlayerDataStorageManager)
317-
{
318-
PlayerDataStorageManager.OnFileListUpdated -= UpdateFileListUI;
319-
}
320-
321303
currentSelectedFile = string.Empty;
322304
currentInventory = null;
323305
}

Assets/Scripts/StandardSamples/UI/Storage/Title/UITitleStorageMenu.cs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public class UITitleStorageMenu : SampleMenu
4646
public GameObject UIFileNameEntryPrefab;
4747

4848
public Text FileContent;
49-
private EOSTitleStorageManager TitleStorageManager;
5049
private List<string> CurrentTags = new List<string>();
5150

5251
protected override void Awake()
@@ -64,13 +63,6 @@ protected override void Awake()
6463

6564
private void Start()
6665
{
67-
TitleStorageManager = EOSManager.Instance.GetOrCreateManager<EOSTitleStorageManager>();
68-
}
69-
70-
protected override void OnDestroy()
71-
{
72-
base.OnDestroy();
73-
EOSManager.Instance.RemoveManager<EOSTitleStorageManager>();
7466
}
7567

7668
public void AddTagOnClick()
@@ -156,7 +148,7 @@ public void QueryListOnClick()
156148
return;
157149
}
158150

159-
TitleStorageManager.QueryFileList(CurrentTags.ToArray(), SetFileListUI);
151+
TitleStorageService.Instance.QueryFileList(CurrentTags.ToArray(), SetFileListUI);
160152
}
161153

162154
private void SetFileListUI(Result result)
@@ -173,7 +165,7 @@ private void SetFileListUI(Result result)
173165
GameObject.Destroy(child.gameObject);
174166
}
175167

176-
foreach (string entry in TitleStorageManager.GetCachedCurrentFileNames())
168+
foreach (string entry in TitleStorageService.Instance.GetCachedCurrentFileNames())
177169
{
178170
GameObject fileNameUIObj = Instantiate(UIFileNameEntryPrefab, FileNameContentParent.transform);
179171
UIFileNameEntry fileNameEntry = fileNameUIObj.GetComponent<UIFileNameEntry>();
@@ -198,14 +190,14 @@ public void DownloadOnClick()
198190
return;
199191
}
200192

201-
if (!TitleStorageManager.GetCachedCurrentFileNames().Contains(FileNameTextBox.InputField.text))
193+
if (!TitleStorageService.Instance.GetCachedCurrentFileNames().Contains(FileNameTextBox.InputField.text))
202194
{
203195
Debug.LogError("UITitleStorageMenu - FileName doesn't exist, cannot be downloaded!");
204196
return;
205197
}
206198

207199
// Check if it's already been downloaded
208-
if (TitleStorageManager.GetLocallyCachedData().TryGetValue(FileNameTextBox.InputField.text, out string cachedData))
200+
if (TitleStorageService.Instance.GetLocallyCachedData().TryGetValue(FileNameTextBox.InputField.text, out string cachedData))
209201
{
210202
Debug.Log("UITitleStorageMenu - FileName '{0}' already downloaded. Display content.");
211203

@@ -214,7 +206,7 @@ public void DownloadOnClick()
214206
return;
215207
}
216208

217-
TitleStorageManager.DownloadFile(FileNameTextBox.InputField.text, UpdateFileContent);
209+
TitleStorageService.Instance.DownloadFile(FileNameTextBox.InputField.text, UpdateFileContent);
218210
}
219211

220212
public void UpdateFileContent(Result result)
@@ -225,7 +217,7 @@ public void UpdateFileContent(Result result)
225217
return;
226218
}
227219

228-
if (TitleStorageManager.GetLocallyCachedData().TryGetValue(FileNameTextBox.InputField.text, out string fileContent))
220+
if (TitleStorageService.Instance.GetLocallyCachedData().TryGetValue(FileNameTextBox.InputField.text, out string fileContent))
229221
{
230222
// Update UI
231223
FileContent.text = fileContent;

0 commit comments

Comments
 (0)