GS2-Limit Script トリガー リファレンス
拡張スクリプトを呼び出す イベントトリガー のリファレンス
トリガー
countUp
カウントアップ
同期実行スクリプト
カウントアップ処理の前に、スクリプトが同期実行されます。
Request
| 型 | 説明 | |
|---|---|---|
| namespace | Namespace | ネームスペース |
| limitModel | LimitModel | 回数制限モデル |
| counter | Counter | カウンター |
| userId | string | ユーザーID |
| countUpValue | int | カウントアップする量 |
| maxValue | int | カウントアップを許容する最大値 |
Result
| 型 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|
| permit | bool | ✓ | カウントアップを許可するか |
実装例
-- Request
local namespace = args.namespace
local limitModel = args.limitModel
local counter = args.counter
local userId = args.userId
local countUpValue = args.countUpValue
local maxValue = args.maxValue
-- Business logic:
local permit = true
-- Result
result = {
permit=permit
}非同期実行スクリプト
カウントアップ処理の後に、スクリプトが非同期実行されます。
Request
| 型 | 説明 | |
|---|---|---|
| namespace | Namespace | ネームスペース |
| limitModel | LimitModel | 回数制限モデル |
| oldCounter | Counter | 更新前のカウンター |
| newCounter | Counter | 更新後のカウンター |
| userId | string | ユーザーID |
| countUpValue | int | カウントアップする量 |
| maxValue | int | カウントアップを許容する最大値 |
実装例
-- Request
local namespace = args.namespace
local limitModel = args.limitModel
local oldCounter = args.oldCounter
local newCounter = args.newCounter
local userId = args.userId
local countUpValue = args.countUpValue
local maxValue = args.maxValue
-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.
result = {
}