API Reference of GS2-News SDK for Game Engine
Model
EzNews
Notification Articles
| Type | Require | Default | Limitation | Description |
---|
section | string | ✓ | | ~ 1024 chars | Section Name |
content | string | ✓ | | ~ 1024 chars | Content Name |
title | string | ✓ | | ~ 1024 chars | Article Headline |
scheduleEventId | string | | | ~ 1024 chars | GS2-Schedule Event GRN |
timestamp | long | ✓ | | | Timestamp (Unix time unit:milliseconds) |
frontMatter | string | ✓ | | ~ 1024 chars | Front Matter |
EzSetCookieRequestEntry
Cookies that need to be set in order to access the announcement content
| Type | Require | Default | Limitation | Description |
---|
key | string | ✓ | | ~ 128 chars | Key value for cookie settings required to view the article |
value | string | ✓ | | ~ 1024 chars | Cookie setting value required to view the article |
Methods
getContentsUrl
Get list of cookies that need to be set to access the announcement article
Request
| Type | Require | Default | Limitation | Description |
---|
namespaceName | string | ✓ | | ~ 128 chars | Namespace Name |
accessToken | string | ✓ | | ~ 128 chars | User Id |
Result
| Type | Description |
---|
items | List<EzSetCookieRequestEntry> | List of cookies that need to be set in order to access the content |
browserUrl | string | URL to access the content |
zipUrl | string | URL to access the announcement contents in ZIP format (Cookie setting is not required for access) |
Implementation Example
var domain = gs2.News.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).News(
);
var result = await domain.GetContentsUrlAsync(
);
List<EzSetCookieRequestEntry> cookies = new List<EzSetCookieRequestEntry>();
var items = result.ToList();
foreach (var item in items)
{
var entry = await item.ModelAsync();
cookies.Add(entry);
}
var browserUrl = domain.BrowserUrl;
var zipUrl = domain.ZipUrl;
var domain = gs2.News.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).News(
);
var future = domain.GetContentsUrlFuture(
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
List<EzSetCookieRequestEntry> cookies = new List<EzSetCookieRequestEntry>();
var result = future.Result;
var items = result.ToList();
foreach (var item in items)
{
var future2 = item.Model();
yield return future2;
var entry = future2.Result;
cookies.Add(entry);
}
var browserUrl = domain.BrowserUrl;
var zipUrl = domain.ZipUrl;
const auto Domain = Gs2->News->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->News(
);
const auto Future = Domain->GetContentsUrl(
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
TArray<EzSetCookieRequestEntryPtr> Cookies;
const auto It = Future->GetTask().Result();
foreach (auto Item in It)
{
const auto Future2 = Item.Model();
Future2->StartSynchronousTask();
if (Future2->GetTask().IsError())
{
return Future2->GetTask().Error();
}
Cookies.Add(Future->GetTask().Result());
}
const auto BrowserUrl = Domain->BrowserUrl;
const auto ZipUrl = Domain->ZipUrl;
listNewses
Retrieve list of announcement articles
Request
| Type | Require | Default | Limitation | Description |
---|
namespaceName | string | ✓ | | ~ 128 chars | Namespace Name |
accessToken | string | ✓ | | ~ 128 chars | User Id |
Result
| Type | Description |
---|
items | List<EzNews> | List of Articles |
contentHash | string | Hash value of article data |
templateHash | string | Hash value of template data |
Implementation Example
var domain = gs2.News.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var items = await domain.NewsesAsync(
).ToListAsync();
var domain = gs2.News.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var it = domain.Newses(
);
List<EzNews> items = new List<EzNews>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->News->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
);
const auto It = Domain->Newses(
);
TArray<Gs2::UE5::News::Model::FEzNewsPtr> Result;
for (auto Item : *It)
{
if (Item.IsError())
{
return false;
}
Result.Add(Item.Current());
}