GS2-News SDK for Game Engine API Reference
Model
EzNews
News Article
Represents a single news article generated from Hugo site data. Each article belongs to a section and content path, and has a title, timestamp, and front matter metadata. Articles can optionally be linked to a GS2-Schedule event to control their display period. The front matter contains additional metadata in JSON format, including an optional weight field for controlling display order.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| section | string | ✓ | ~ 1024 chars | Section Name The section (category) to which this article belongs, corresponding to the Hugo content directory structure. Used to organize articles into logical groups for display. | ||
| content | string | ✓ | ~ 1024 chars | Content The content path identifier for this article within its section. Together with the section, uniquely identifies the article’s location in the Hugo content structure. | ||
| title | string | ✓ | ~ 1024 chars | Article Headline The title of the news article, typically defined in the Hugo front matter. Displayed as the headline when listing articles for the player. | ||
| scheduleEventId | string | ~ 1024 chars | GS2-Schedule Event GRN | |||
| timestamp | long | ✓ | Timestamp Unix time, milliseconds | |||
| frontMatter | string | ✓ | ~ 1024 chars | Front Matter Metadata associated with the article in JSON format, originally defined in the Hugo markdown front matter. May contain arbitrary fields such as weight (for controlling display order), tags, categories, and other custom properties. |
EzSetCookieRequestEntry
Set Cookie Request Entry
Represents a cookie key-value pair that must be set in the browser/WebView to access the news article web content. The client must set these cookies before loading the article URLs to ensure authorized access to the content.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| key | string | ✓ | ~ 128 chars | Cookie Key The name of the cookie that must be set for authenticated access to the news content. Maximum 128 characters. | ||
| value | string | ✓ | ~ 1024 chars | Cookie Value The value of the cookie that must be set for authenticated access to the news content. Maximum 1024 characters. |
Methods
getContentsUrl
Get the URL and cookies needed to display news content
Retrieves the information required to display news articles in a WebView or browser. News content is hosted as web pages, so to display them you need: (1) cookies for authentication, and (2) the URL to open. The response includes a browser URL (requires cookies to be set first) and a ZIP URL (for downloading all content without cookies — useful for offline or custom rendering). Use this before opening a news article — for example, call this API, set the returned cookies in the WebView, then navigate to the browser URL to show the article. Alternatively, download the ZIP to render the content natively in your game UI.
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| gameSession | GameSession | ✓ | GameSession |
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(Future2->GetTask().Result());
}
const auto BrowserUrl = Domain->BrowserUrl;
const auto ZipUrl = Domain->ZipUrl;listNewses
Get a list of news articles
Retrieves the list of in-game news articles (announcements) for the player. News articles are HTML-based web content managed through GS2 — for example, maintenance notices, event announcements, update patch notes, and campaign information. The response also includes hash values for cache validation, so you can check if the content has changed since the last fetch. Use this to build an in-game news/announcements screen — for example, showing a list of articles like “Maintenance on March 1st”, “New Event: Spring Festival”, “Version 2.5 Update Notes”.
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| gameSession | GameSession | ✓ | GameSession |
Result
| Type | Description | |
|---|---|---|
| items | List<EzNews> | List of News Articles |
| contentHash | string | Hash value of News 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());
}