API Reference of GS2-Schedule SDK for Game Engine
Model
EzTrigger
Trigger
A trigger is an entity that defines the starting point for the beginning of an event when realizing different event durations for different game players.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
triggerId | string | ✓ | ~ 1024 chars | Trigger Name | |
name | string | ✓ | ~ 128 chars | Trigger Name | |
createdAt | long | ✓ | Datetime of creation | ||
expiresAt | long | ✓ | Trigger Expiration Date |
EzEvent
Event
Two types of event durations exist: absolute and relative. Absolute periods are fixed periods, such as January 1, 2021 00:00(UTC) to January 7, 2021 23:59(UTC). A relative period is an event period that varies from one game player to another, such as 24 hours from the time the trigger is pulled.
The event can be set to repeat itself as well as the duration of the event. An event period can be set up so that only Monday from 10:00 to 11:00 is included in the event period.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
name | string | ✓ | ~ 128 chars | Event Type Name | |
metadata | string | ~ 2048 chars | metadata | ||
scheduleType | enum [‘absolute’, ‘relative’] | ✓ | ~ 128 chars | Type of Event Period | |
repeatType | enum [‘always’, ‘daily’, ‘weekly’, ‘monthly’] | ✓ | “always” | ~ 128 chars | Type of repetition |
absoluteBegin | long | {scheduleType} == “absolute” | Event start date and time | ||
absoluteEnd | long | {scheduleType} == “absolute” | Event end date and time | ||
repeatBeginDayOfMonth | int | {repeatType} == “monthly” | 1 ~ 31 | Event repeat start date (If the value exceeds the days of the month, it is treated as the last day.) | |
repeatEndDayOfMonth | int | {repeatType} == “monthly” | 1 ~ 31 | Event repeat end date (If the value exceeds the days of the month, it is treated as the last day.) | |
repeatBeginDayOfWeek | enum [‘sunday’, ‘monday’, ’tuesday’, ‘wednesday’, ’thursday’, ‘friday’, ‘saturday’] | {repeatType} == “weekly” | ~ 128 chars | Repeat start day of event | |
repeatEndDayOfWeek | enum [‘sunday’, ‘monday’, ’tuesday’, ‘wednesday’, ’thursday’, ‘friday’, ‘saturday’] | {repeatType} == “weekly” | ~ 128 chars | Repeat event end day of the week | |
repeatBeginHour | int | {repeatType} in [“daily”, “weekly”, “monthly”] | ~ 23 | Repeat event start time | |
repeatEndHour | int | {repeatType} in [“daily”, “weekly”, “monthly”] | ~ 23 | Repeat event end time | |
relativeTriggerName | string | {scheduleType} == “relative” | ~ 128 chars | Trigger the start of the event |
EzRepeatSchedule
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
repeatCount | int | ✓ | ~ 2147483646 | Number of times to repeat | |
currentRepeatStartAt | long | Start date and time of repeating event | |||
currentRepeatEndAt | long | End date and time of repeating event | |||
lastRepeatEndAt | long | End date and time of last event | |||
nextRepeatStartAt | long | Start date and time of next event |
Methods
getTrigger
Get the trigger being pulled
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
triggerName | string | ✓ | ~ 128 chars | Trigger Name | |
accessToken | string | ✓ | ~ 128 chars | User Id |
Result
Type | Description | |
---|---|---|
item | EzTrigger | Trigger |
Implementation Example
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Trigger(
triggerName: "trigger1"
);
var item = await domain.ModelAsync();
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Trigger(
triggerName: "trigger1"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Schedule->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Trigger(
"trigger1" // triggerName
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Trigger(
triggerName: "trigger1"
);
// Start event handling
var callbackId = domain.Subscribe(
value => {
// Called when the value changes
// The "value" is passed the value after the change.
}
);
// Stop event handling
domain.Unsubscribe(callbackId);
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Trigger(
triggerName: "trigger1"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Schedule->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Trigger(
"trigger1" // triggerName
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Schedule::Model::FTrigger> value) {
// Called when the value changes
// The "value" is passed the value after the change.
}
);
// Stop event handling
Domain->Unsubscribe(CallbackId);
Warning
This event is called when the value in the local cache that the SDK has is changed.
The local cache will only be changed by executing the SDK’s API, or by executing a stamp sheet via GS2-Distributor with GS2-Gateway notification enabled, or by executing a GS2-JobQueue with GS2-Gateway notification enabled. GS2-Gateway notification enabled.
Therefore, callbacks will not be invoked if the value is changed in any other way.
listTriggers
Get list of triggers being pulled
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
accessToken | string | ✓ | ~ 128 chars | User Id |
Result
Type | Description | |
---|---|---|
items | List<EzTrigger> | List of Triggers |
nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var items = await domain.TriggersAsync(
).ToListAsync();
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var it = domain.Triggers(
);
List<EzTrigger> items = new List<EzTrigger>();
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->Schedule->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
);
const auto It = Domain->Triggers(
);
for (auto Item : *It)
{
}
Value change event handling
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
// Start event handling
var callbackId = domain.SubscribeTriggers(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeTriggers(callbackId);
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var it = domain.Triggers(
);
List<EzTrigger> items = new List<EzTrigger>();
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->Schedule->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
);
// Start event handling
const auto CallbackId = Domain->SubscribeTriggers(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeTriggers(CallbackId);
Warning
This event is called when the value in the local cache that the SDK has is changed.
The local cache will only be changed by executing the SDK’s API, or by executing a stamp sheet via GS2-Distributor with GS2-Gateway notification enabled, or by executing a GS2-JobQueue with GS2-Gateway notification enabled. GS2-Gateway notification enabled.
Therefore, callbacks will not be invoked if the value is changed in any other way.
getEvent
Retrieve ongoing events
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
eventName | string | ✓ | ~ 128 chars | Event Type Name | |
accessToken | string | ✓ | ~ 128 chars | User Id |
Result
Type | Description | |
---|---|---|
item | EzEvent | Event |
inSchedule | bool | Whether in schedule |
scheduleStartAt | long | Schedule start time |
scheduleEndAt | long | Schedule end time |
repeatSchedule | EzRepeatSchedule | Repeat Schedule |
Implementation Example
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Event(
eventName: "event-0001"
);
var item = await domain.ModelAsync();
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Event(
eventName: "event-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Schedule->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Event(
"event-0001" // eventName
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Event(
eventName: "event-0001"
);
// Start event handling
var callbackId = domain.Subscribe(
value => {
// Called when the value changes
// The "value" is passed the value after the change.
}
);
// Stop event handling
domain.Unsubscribe(callbackId);
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Event(
eventName: "event-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Schedule->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Event(
"event-0001" // eventName
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Schedule::Model::FEvent> value) {
// Called when the value changes
// The "value" is passed the value after the change.
}
);
// Stop event handling
Domain->Unsubscribe(CallbackId);
Warning
This event is called when the value in the local cache that the SDK has is changed.
The local cache will only be changed by executing the SDK’s API, or by executing a stamp sheet via GS2-Distributor with GS2-Gateway notification enabled, or by executing a GS2-JobQueue with GS2-Gateway notification enabled. GS2-Gateway notification enabled.
Therefore, callbacks will not be invoked if the value is changed in any other way.
listEvents
Get list of events currently being held
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
accessToken | string | ✓ | ~ 128 chars | User Id |
Result
Type | Description | |
---|---|---|
items | List<EzEvent> | List of Events |
Implementation Example
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var items = await domain.EventsAsync(
).ToListAsync();
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var it = domain.Events(
);
List<EzEvent> items = new List<EzEvent>();
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->Schedule->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
);
const auto It = Domain->Events(
);
for (auto Item : *It)
{
}
Value change event handling
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
// Start event handling
var callbackId = domain.SubscribeEvents(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeEvents(callbackId);
var domain = gs2.Schedule.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var it = domain.Events(
);
List<EzEvent> items = new List<EzEvent>();
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->Schedule->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
);
// Start event handling
const auto CallbackId = Domain->SubscribeEvents(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeEvents(CallbackId);
Warning
This event is called when the value in the local cache that the SDK has is changed.
The local cache will only be changed by executing the SDK’s API, or by executing a stamp sheet via GS2-Distributor with GS2-Gateway notification enabled, or by executing a GS2-JobQueue with GS2-Gateway notification enabled. GS2-Gateway notification enabled.
Therefore, callbacks will not be invoked if the value is changed in any other way.