Skip to main content
Version: 5.15.0

Backend.CDN.Content.Local.Save

public void Backend.CDN.Content.Local.Save(List< ContentItem > contentList, Action< bool, Exception > callback);
public bool Backend.CDN.Content.Local.Save(List< ContentItem > contentList, out Exception exception);

Parameter

ValueTypeDescription
contentTableListList< ContentTableItem >Can be called using Backend.CDN.Content.Table.Get().

Description

Saves the chart locally.

  • This method cannot be called via SendQueue.

Example

Synchronous

void Save() 
{
BackEnd.Content.BackendContentTableReturnObject callback;

// Load chart table
callback = Backend.CDN.Content.Table.Get();

if(callback.IsSuccess() == false) {
Debug.LogError(callback);
return;
}

BackEnd.Content.BackendContentReturnObject callback2 = null;

// Look up loaded chart content
callback2 = Backend.CDN.Content.Get(callback.GetContentTableItemList());

if (callback2.IsSuccess() == false)
{
Debug.LogError("GetContents : Fail : " + callback2);
return;
}

if(Backend.CDN.Content.Local.Save(callback2.GetContentList(), out Exception e) == false)
{
Debug.LogError("Save Error : " + e);
return;
}

Debug.Log("Successfully saved locally");
}

Asynchronous

private void GetProgress(int totalCount, int remainCount, string fileName)
{
Debug.Log("totalCount : " + totalCount + " remainCount : " + remainCount + " fileName : " + fileName);
}

public void GetAsync()
{
StartCoroutine(GetAsyncIEnumerator());
}

IEnumerator GetAsyncIEnumerator()
{
BackEnd.Content.BackendContentTableReturnObject callback = null;

Backend.CDN.Content.Table.Get(bro =>
{
callback = bro;
});

yield return new WaitUntil(() => callback != null);

if(callback.IsSuccess() == false) {
Debug.LogError(callback);
yield break;
}

BackEnd.Content.BackendContentReturnObject callback2 = null;

Backend.CDN.Content.Get(callback.GetContentTableItemList(), GetProgress, bro =>
{
callback2 = bro;
});

yield return new WaitUntil(() => callback2 != null);

if (callback2.IsSuccess() == false)
{
Debug.LogError("GetContents : Fail : " + callback2);
yield break;
}


bool isDone = false;

foreach (var item in callback2.GetContentList())
{
Debug.Log(item.chartName);
}

Backend.CDN.Content.Local.Save(callback2.GetContentList(), (isSuccess, exception) =>
{
isDone = true;
if (isSuccess == false)
{
Debug.LogError("Local Save Fail : " + exception);
return;
}

Debug.Log("Local Save Success");
});

yield return new WaitUntil(() => isDone);
}