API Reference of GS2-Log SDK for Game Engine
Model
EzInGameLog
In-game log
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
timestamp | long | ✓ | Timestamp (Unix time unit:milliseconds) | ||
userId | string | ~ 128 chars | User Id | ||
tags | List<EzInGameLogTag> | ~ 20 items | Tags | ||
payload | string | ✓ | ~ 10485760 chars | Payload in JSON format |
EzInGameLogTag
In-game log tag
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
key | string | ✓ | ~ 64 chars | Tag Key | |
value | string | ✓ | ~ 128 chars | Tag Value |
Methods
sendInGameLog
Send in-game logs
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
tags | List<EzInGameLogTag> | ~ 20 items | Tags | ||
payload | string | ✓ | ~ 10485760 chars | Payload in JSON format | |
accessToken | string | ~ 128 chars | User Id |
Result
Type | Description | |
---|---|---|
item | EzInGameLog | In-game log |
Implementation Example
var domain = gs2.Log.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var result = await domain.SendInGameLogAsync(
payload: "{\"category\": \"use-item\", \"count\": 1, \"itemId\": \"item-0001\"}",
tags: new List<Gs2.Unity.Gs2Log.Model.EzInGameLogTag> {
new Gs2.Unity.Gs2Log.Model.EzInGameLogTag() {
Key = "tag1",
Value = "value1",
},
new Gs2.Unity.Gs2Log.Model.EzInGameLogTag() {
Key = "tag2",
Value = "value2",
},
}
);
var item = await result.ModelAsync();
var domain = gs2.Log.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var future = domain.SendInGameLogFuture(
payload: "{\"category\": \"use-item\", \"count\": 1, \"itemId\": \"item-0001\"}",
tags: new List<Gs2.Unity.Gs2Log.Model.EzInGameLogTag> {
new Gs2.Unity.Gs2Log.Model.EzInGameLogTag() {
Key = "tag1",
Value = "value1",
},
new Gs2.Unity.Gs2Log.Model.EzInGameLogTag() {
Key = "tag2",
Value = "value2",
},
}
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var future2 = future.Result.Model();
yield return future2;
if (future2.Error != null)
{
onError.Invoke(future2.Error, null);
yield break;
}
var result = future2.Result;
const auto Domain = Gs2->Log->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
);
const auto Future = Domain->SendInGameLog(
"{\"category\": \"use-item\", \"count\": 1, \"itemId\": \"item-0001\"}", // payload
[]
{
auto v = MakeShared<TArray<TSharedPtr<Gs2::UE5::Log::Model::FEzInGameLogTag>>>();
v->Add(
MakeShared<Gs2::UE5::Log::Model::FEzInGameLogTag>()
->WithKey(TOptional<FString>("tag1"))
->WithValue(TOptional<FString>("value1"))
);
v->Add(
MakeShared<Gs2::UE5::Log::Model::FEzInGameLogTag>()
->WithKey(TOptional<FString>("tag2"))
->WithValue(TOptional<FString>("value2"))
);
return v;
}() // tags
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
// obtain changed values / result values
const auto Future2 = Future->GetTask().Result()->Model();
Future2->StartSynchronousTask();
if (Future2->GetTask().IsError())
{
return Future2->GetTask().Error();
}
const auto Result = Future2->GetTask().Result();