GS2-Matchmaking SDK for Game Engine API リファレンス

モデル

EzGathering

ギャザリング

マッチメイキングによって集められたゲームプレイヤーグループを表すエンティティです。 マッチメイキング用のパラメータを複数持っており、パラメータを総合的に判断してプレイヤーをグルーピングします。

必須デフォルト値の制限説明
gatheringIdstring~ 1024文字ギャザリングGRN
namestringUUID~ 128文字ギャザリング名
attributeRangesList<EzAttributeRange>[]募集条件
capacityOfRolesList<EzCapacityOfRole>[]募集枠
allowUserIdsList<string>[]参加を許可するユーザ
metadatastring~ 1024文字メタデータ
expiresAtlongギャザリングの有効期限
createdAtlong作成日時
updatedAtlong最終更新日時

EzRatingModel

レーティングモデル

GS2 ではレーティングアルゴリズムとして Glicko-2 を採用しています。 Glicko-2 には複数のパラメータがありますが、GS2-Matchmaking ではそれらを総合的に表す ボラティリティ という1つのパラメータに集約しています。 ボラティリティ は変化の大きさを表すパラメータで、値が大きいほどレーティングの値の変動量が大きくなります。

必須デフォルト値の制限説明
namestring~ 128文字レーティングモデル名
metadatastring~ 128文字メタデータ
volatilityint1001 ~ 350レート値の変動の大きさ

EzAttributeRange

必須デフォルト値の制限説明
namestring~ 128文字属性名
minint0~ 2147483646ギャザリング参加可能な属性値の最小値
maxint0~ 2147483646ギャザリング参加可能な属性値の最大値

EzCapacityOfRole

必須デフォルト値の制限説明
roleNamestring“default”~ 128文字ロール名
roleAliasesList<string>[]ロール名の別名リスト
capacityint1 ~ 256募集人数
participantsList<EzPlayer>[]参加者のプレイヤー情報リスト

EzAttribute

必須デフォルト値の制限説明
namestring~ 128文字属性名
valueint0~ 2147483646属性値

EzPlayer

必須デフォルト値の制限説明
userIdstring~ 128文字ユーザーID
attributesList<EzAttribute>[]属性値のリスト
roleNamestring“default”~ 128文字ロール名
denyUserIdsList<string>[]参加を拒否するユーザIDリスト

EzRating

レーティング

ゲームプレイヤー毎の現在のレーティングの値を保持するエンティティです。

必須デフォルト値の制限説明
ratingIdstring~ 1024文字レーティングGRN
namestring~ 128文字レーティング名
userIdstring~ 128文字ユーザーID
rateValuefloat1500.0~ 65535.0
createdAtlong作成日時
updatedAtlong最終更新日時

EzGameResult

必須デフォルト値の制限説明
rankint~ 2147483646順位
userIdstring~ 128文字ユーザーID

EzBallot

必須デフォルト値の制限説明
userIdstring~ 128文字ユーザーID
ratingNamestring~ 128文字レーティング計算に使用するレーティング名
gatheringNamestring~ 128文字投票対象のギャザリング名
numberOfPlayerint2 ~ 10参加人数

EzSignedBallot

必須デフォルト値の制限説明
bodystring~ 1024文字投票用紙の署名対象のデータ
signaturestring~ 256文字投票用紙の署名

EzTimeSpan

必須デフォルト値の制限説明
daysint0~ 365現在時刻からの日数
hoursint0~ 24現在時刻からの時間
minutesint0~ 60現在時刻からの分

メソッド

cancelMatchmaking

マッチメイキングをキャンセルし、参加中のギャザリングから離脱。

ギャザリングから離脱する前にマッチメイキングが完了した場合は、NotFoundException(404エラー) が発生し失敗します。

Request

必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
gatheringNamestringUUID~ 128文字ギャザリング名
accessTokenstring~ 128文字ユーザーID

Result

説明
itemEzGatheringキャンセルしたギャザリング

実装例

    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Gathering(
        gatheringName: "gathering-0001"
    );
    var result = await domain.CancelMatchmakingAsync(
    );
    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Gathering(
        gatheringName: "gathering-0001"
    );
    var future = domain.CancelMatchmaking(
    );
    yield return future;
    if (future.Error != null)
    {
        onError.Invoke(future.Error, null);
        yield break;
    }
    const auto Domain = Gs2->Matchmaking->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        AccessToken
    )->Gathering(
        "gathering-0001" // gatheringName
    );
    const auto Future = Domain->CancelMatchmaking(
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }

createGathering

ギャザリングを新規作成

Player に指定する自身のプレイヤー情報のユーザIDは省略できます。 expiresAtを指定することでギャザリングの有効期限を設定することができます。 有効期限を用いない場合、古いギャザリングが残り続けマッチングが成立したときには、 ユーザーがゲームから離脱している可能性があります。 有効期限を用いる場合は、有効期限が来るたびにユーザーにギャザリングの再作成を促す仕組みにしてください。

Request

必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
accessTokenstring~ 128文字ユーザーID
playerEzPlayer自身のプレイヤー情報
attributeRangesList<EzAttributeRange>[]募集条件
capacityOfRolesList<EzCapacityOfRole>[]募集枠
allowUserIdsList<string>[]参加を許可するユーザ
expiresAtlongギャザリングの有効期限
expiresAtTimeSpanEzTimeSpan有効期限までの時間

Result

説明
itemEzGathering作成したギャザリング

実装例

    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var result = await domain.CreateGatheringAsync(
        player:     new Gs2.Unity.Gs2Matchmaking.Model.EzPlayer {
                Attributes = new List<Gs2.Unity.Gs2Matchmaking.Model.EzAttribute> {
                new Gs2.Unity.Gs2Matchmaking.Model.EzAttribute {
                    Name = "stage",
                    Value = 1,
                },
                new Gs2.Unity.Gs2Matchmaking.Model.EzAttribute {
                    Name = "level",
                    Value = 10,
                },
            },
            },
        attributeRanges: new Gs2.Unity.Gs2Matchmaking.Model.EzAttributeRange[] {
            new Gs2.Unity.Gs2Matchmaking.Model.EzAttributeRange {
                Name = "stage",
                Min = 1,
                Max = 1,
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzAttributeRange {
                Name = "level",
                Min = 0,
                Max = 10,
            },
        },
        capacityOfRoles: new Gs2.Unity.Gs2Matchmaking.Model.EzCapacityOfRole[] {
            new Gs2.Unity.Gs2Matchmaking.Model.EzCapacityOfRole {
                RoleName = "default",
                Capacity = 4,
            },
        },
        allowUserIds: null,
        expiresAt: null,
        expiresAtTimeSpan: null
    );
    var item = await result.ModelAsync();
    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var future = domain.CreateGathering(
        player:     new Gs2.Unity.Gs2Matchmaking.Model.EzPlayer {
                Attributes = new List<Gs2.Unity.Gs2Matchmaking.Model.EzAttribute> {
                new Gs2.Unity.Gs2Matchmaking.Model.EzAttribute {
                    Name = "stage",
                    Value = 1,
                },
                new Gs2.Unity.Gs2Matchmaking.Model.EzAttribute {
                    Name = "level",
                    Value = 10,
                },
            },
            },
        attributeRanges: new Gs2.Unity.Gs2Matchmaking.Model.EzAttributeRange[] {
            new Gs2.Unity.Gs2Matchmaking.Model.EzAttributeRange {
                Name = "stage",
                Min = 1,
                Max = 1,
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzAttributeRange {
                Name = "level",
                Min = 0,
                Max = 10,
            },
        },
        capacityOfRoles: new Gs2.Unity.Gs2Matchmaking.Model.EzCapacityOfRole[] {
            new Gs2.Unity.Gs2Matchmaking.Model.EzCapacityOfRole {
                RoleName = "default",
                Capacity = 4,
            },
        },
        allowUserIds: null,
        expiresAt: null,
        expiresAtTimeSpan: null
    );
    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->Matchmaking->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        AccessToken
    );
    const auto Future = Domain->CreateGathering(
        MakeShared<Gs2::Matchmaking::Model::FPlayer>()
            ->WithAttributes([]
            {
                const auto v = MakeShared<TArray<TSharedPtr<Gs2::Matchmaking::Model::FAttribute>>>();
                v->Add(MakeShared<Gs2::Matchmaking::Model::FAttribute>()
                    ->WithName(TOptional<FString>("stage"))
                    ->WithValue(TOptional<int32>(1)));
                v->Add(MakeShared<Gs2::Matchmaking::Model::FAttribute>()
                    ->WithName(TOptional<FString>("level"))
                    ->WithValue(TOptional<int32>(10)));
                return v;
            }()),
        []
        {
            const auto v = MakeShared<TArray<TSharedPtr<Gs2::Matchmaking::Model::FAttributeRange>>>();
            v->Add(MakeShared<Gs2::Matchmaking::Model::FAttributeRange>()
                ->WithName(TOptional<FString>("stage"))
                ->WithMin(TOptional<int32>(1))
                ->WithMax(TOptional<int32>(1)));
            v->Add(MakeShared<Gs2::Matchmaking::Model::FAttributeRange>()
                ->WithName(TOptional<FString>("level"))
                ->WithMin(TOptional<int32>(0))
                ->WithMax(TOptional<int32>(10)));
            return v;
        }(), // attributeRanges
        []
        {
            const auto v = MakeShared<TArray<TSharedPtr<Gs2::Matchmaking::Model::FCapacityOfRole>>>();
            v->Add(MakeShared<Gs2::Matchmaking::Model::FCapacityOfRole>()
                ->WithRoleName(TOptional<FString>("default"))
                ->WithCapacity(TOptional<int32>(4)));
            return v;
        }(), // capacityOfRoles
        nullptr, // allowUserIds
        nullptr, // expiresAt
        nullptr // expiresAtTimeSpan
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }

    // obtain changed values / result values
    const auto Future2 = Future->GetTask().Result()->Model();
    Future2->StartSynchronousTask();
    if (!TestFalse(WHAT, Future2->GetTask().IsError())) return false;
    const auto Result = Future2->GetTask().Result();

doMatchmaking

すでに存在する中で、自分が参加できるギャザリングを探して参加

一定時間 検索を行い、対象が見つからなかったときには マッチメイキングの状態を保持するトークン を返す。 次回 マッチメイキングの状態を保持するトークン をつけて再度リクエストを出すことで、前回の続きから検索処理を再開できる。 すべてのギャザリングを検索したが、参加できるギャザリングが存在しなかった場合はギャザリングもトークンもどちらも null が応答される。

Request

必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
accessTokenstring~ 128文字ユーザーID
playerEzPlayer自身のプレイヤー情報
matchmakingContextTokenstring~ 5120文字検索の再開に使用する マッチメイキングの状態を保持するトークン

Result

説明
itemEzGathering参加したギャザリング
matchmakingContextTokenstringマッチメイキングの状態を保持するトークン

実装例

    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var items = await domain.DoMatchmakingAsync(
    ).ToListAsync();
    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var it = domain.DoMatchmaking(
    );

    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->Matchmaking->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        AccessToken
    );
    const auto It = Domain->DoMatchmaking( // player
    );
    for (auto Item : *It)
    {

    }

getGathering

最新のギャザリングの状態を取得

Request

必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
gatheringNamestringUUID~ 128文字ギャザリング名

Result

説明
itemEzGatheringギャザリング

実装例

    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).User(
        userId: "user-0001"
    ).Gathering(
        gatheringName: "gathering-0001"
    );
    var item = await domain.ModelAsync();
    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).User(
        userId: "user-0001"
    ).Gathering(
        gatheringName: "gathering-0001"
    );
    var future = domain.Model();
    yield return future;
    var item = future.Result;
    const auto Domain = Gs2->Matchmaking->Namespace(
        "namespace-0001" // namespaceName
    )->User(
        "user-0001" // userId
    )->Gathering(
        "gathering-0001" // gatheringName
    );
    const auto item = Domain.Model();

updateGathering

ギャザリングの募集条件を変更

Request

必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
gatheringNamestringUUID~ 128文字ギャザリング名
accessTokenstring~ 128文字ユーザーID
attributeRangesList<EzAttributeRange>[]募集条件

Result

説明
itemEzGathering更新したギャザリング

実装例

    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Gathering(
        gatheringName: "gathering-0001"
    );
    var result = await domain.UpdateGatheringAsync(
        attributeRanges: new Gs2.Unity.Gs2Matchmaking.Model.EzAttributeRange[] {
            new Gs2.Unity.Gs2Matchmaking.Model.EzAttributeRange {
                Name = "stage",
                Min = 1,
                Max = 1,
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzAttributeRange {
                Name = "level",
                Min = 0,
                Max = 50,
            },
        }
    );
    var item = await result.ModelAsync();
    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Gathering(
        gatheringName: "gathering-0001"
    );
    var future = domain.UpdateGathering(
        attributeRanges: new Gs2.Unity.Gs2Matchmaking.Model.EzAttributeRange[] {
            new Gs2.Unity.Gs2Matchmaking.Model.EzAttributeRange {
                Name = "stage",
                Min = 1,
                Max = 1,
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzAttributeRange {
                Name = "level",
                Min = 0,
                Max = 50,
            },
        }
    );
    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->Matchmaking->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        AccessToken
    )->Gathering(
        "gathering-0001" // gatheringName
    );
    const auto Future = Domain->UpdateGathering(
        []
        {
            const auto v = MakeShared<TArray<TSharedPtr<Gs2::Matchmaking::Model::FAttributeRange>>>();
            v->Add(MakeShared<Gs2::Matchmaking::Model::FAttributeRange>()
                ->WithName(TOptional<FString>("stage"))
                ->WithMin(TOptional<int32>(1))
                ->WithMax(TOptional<int32>(1)));
            v->Add(MakeShared<Gs2::Matchmaking::Model::FAttributeRange>()
                ->WithName(TOptional<FString>("level"))
                ->WithMin(TOptional<int32>(0))
                ->WithMax(TOptional<int32>(50)));
            return v;
        }() // attributeRanges
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }

    // obtain changed values / result values
    const auto Future2 = Future->GetTask().Result()->Model();
    Future2->StartSynchronousTask();
    if (!TestFalse(WHAT, Future2->GetTask().IsError())) return false;
    const auto Result = Future2->GetTask().Result();

getRatingModel

レーティング名を指定してレーティングモデルを取得

Request

必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
ratingNamestring~ 128文字レーティングモデル名

Result

説明
itemEzRatingModelレーティングモデル

実装例

    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).RatingModel(
        ratingName: "mode1"
    );
    var item = await domain.ModelAsync();
    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).RatingModel(
        ratingName: "mode1"
    );
    var future = domain.Model();
    yield return future;
    var item = future.Result;
    const auto Domain = Gs2->Matchmaking->Namespace(
        "namespace-0001" // namespaceName
    )->RatingModel(
        "mode1" // ratingName
    );
    const auto item = Domain.Model();

listRatingModels

レーティングモデルの一覧を取得

Request

必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名

Result

説明
itemsList<EzRatingModel>レーティングモデルのリスト

実装例

    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    );
    var items = await domain.RatingModelsAsync(
    ).ToListAsync();
    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    );
    var it = domain.RatingModels(
    );
    List<EzRatingModel> items = new List<EzRatingModel>();
    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->Matchmaking->Namespace(
        "namespace-0001" // namespaceName
    );
    const auto It = Domain->RatingModels(
    );
    for (auto Item : *It)
    {

    }

getRating

レーティングを取得

Request

必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
accessTokenstring~ 128文字ユーザーID
ratingNamestring~ 128文字レーティング名

Result

説明
itemEzRatingレーティング

実装例

    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Rating(
        ratingName: "rating-0001"
    );
    var item = await domain.ModelAsync();
    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Rating(
        ratingName: "rating-0001"
    );
    var future = domain.Model();
    yield return future;
    var item = future.Result;
    const auto Domain = Gs2->Matchmaking->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        AccessToken
    )->Rating(
        "rating-0001" // ratingName
    );
    const auto item = Domain.Model();

listRatings

レーティングの一覧を取得

Request

必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
accessTokenstring~ 128文字ユーザーID
pageTokenstring~ 1024文字データの取得を開始する位置を指定するトークン
limitint301 ~ 1000データの取得件数

Result

説明
itemsList<EzRating>レーティングのリスト
nextPageTokenstringリストの続きを取得するためのページトークン

実装例

    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var items = await domain.RatingsAsync(
    ).ToListAsync();
    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var it = domain.Ratings(
    );
    List<EzRating> items = new List<EzRating>();
    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->Matchmaking->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        AccessToken
    );
    const auto It = Domain->Ratings(
    );
    for (auto Item : *It)
    {

    }

createVote

投票用紙を作成

Request

必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
ratingNamestring~ 128文字レーティング名
gatheringNamestring~ 128文字投票対象のギャザリング名
accessTokenstring~ 128文字ユーザーID

Result

説明
itemEzBallot投票用紙
bodystring署名対象のデータ
signaturestring署名データ

実装例

    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Ballot(
        ratingName: "rating-0001",
        gatheringName: "gathering-0001",
        numberOfPlayer: 4,
        keyId: "key-0001"
    );
    var item = await domain.ModelAsync();
    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Ballot(
        ratingName: "rating-0001",
        gatheringName: "gathering-0001",
        numberOfPlayer: 4,
        keyId: "key-0001"
    );
    var future = domain.Model();
    yield return future;
    var item = future.Result;
    const auto Domain = Gs2->Matchmaking->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        AccessToken
    )->Ballot(
        "rating-0001", // ratingName
        "gathering-0001", // gatheringName
        4, // numberOfPlayer
        "key-0001" // keyId
    );
    const auto item = Domain.Model();

vote

対戦結果を投票します。

投票は最初の投票が行われてから5分以内に行う必要があります。 つまり、結果は即座に反映されず、投票開始からおよそ5分後または全てのプレイヤーが投票を行った際に結果が反映されます。 5分以内に全ての投票用紙を回収できなかった場合はその時点の投票内容で多数決をとって結果を決定します。 各結果の投票数が同一だった場合は結果は捨てられます(スクリプトで挙動を変更可)。

結果を即座に反映したい場合は、勝利した側の代表プレイヤーが投票用紙を各プレイヤーから集めて voteMultiple を呼び出すことで結果を即座に反映できます。

Request

必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
ballotBodystring~ 1024文字投票用紙の署名対象のデータ
ballotSignaturestring~ 256文字投票用紙の署名
gameResultsList<EzGameResult>投票内容。対戦を行ったプレイヤーグループ1に所属するユーザIDのリスト

Result

説明
itemEzBallot投票用紙

実装例

    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    );
    var result = await domain.VoteAsync(
        ballotBody: "ballotBody",
        ballotSignature: "ballotSignature",
        gameResults: new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult[] {
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 1,
                UserId = "user-0001",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 2,
                UserId = "user-0002",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 2,
                UserId = "user-0003",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 3,
                UserId = "user-0004",
            },
        }
    );
    var item = await result.ModelAsync();
    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    );
    var future = domain.Vote(
        ballotBody: "ballotBody",
        ballotSignature: "ballotSignature",
        gameResults: new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult[] {
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 1,
                UserId = "user-0001",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 2,
                UserId = "user-0002",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 2,
                UserId = "user-0003",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 3,
                UserId = "user-0004",
            },
        }
    );
    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->Matchmaking->Namespace(
        "namespace-0001" // namespaceName
    );
    const auto Future = Domain->Vote(
        "ballotBody",
        "ballotSignature",
        []
        {
            const auto v = MakeShared<TArray<TSharedPtr<Gs2::Matchmaking::Model::FGameResult>>>();
            v->Add({'rank': 1, 'userId': 'user-0001'});
            v->Add({'rank': 2, 'userId': 'user-0002'});
            v->Add({'rank': 2, 'userId': 'user-0003'});
            v->Add({'rank': 3, 'userId': 'user-0004'});
            return v;
        }() // gameResults
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }

    // obtain changed values / result values
    const auto Future2 = Future->GetTask().Result()->Model();
    Future2->StartSynchronousTask();
    if (!TestFalse(WHAT, Future2->GetTask().IsError())) return false;
    const auto Result = Future2->GetTask().Result();

voteMultiple

対戦結果をまとめて投票します。

ゲームに勝利した側が他プレイヤーの投票用紙を集めてまとめて投票するのに使用します。 『勝利した側』としているのは、敗北した側が自分たちが勝ったことにして報告することにインセンティブはありますが、その逆はないためです。 負けた側が投票用紙を渡してこない可能性がありますが、その場合も過半数の投票用紙があれば結果を通すことができます。

Request

必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
signedBallotsList<EzSignedBallot>署名付の投票用紙リスト
gameResultsList<EzGameResult>投票内容。対戦を行ったプレイヤーグループ1に所属するユーザIDのリスト

Result

説明
itemEzBallot投票用紙

実装例

    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    );
    var result = await domain.VoteMultipleAsync(
        signedBallots: new Gs2.Unity.Gs2Matchmaking.Model.EzSignedBallot[] {
            new Gs2.Unity.Gs2Matchmaking.Model.EzSignedBallot
            {
                Body = "aaa",
                Signature = "bbb",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzSignedBallot
            {
                Body = "aaa",
                Signature = "bbb",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzSignedBallot
            {
                Body = "aaa",
                Signature = "bbb",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzSignedBallot
            {
                Body = "aaa",
                Signature = "bbb",
            },
        },
        gameResults: new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult[] {
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 1,
                UserId = "user-0001",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 2,
                UserId = "user-0002",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 2,
                UserId = "user-0003",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 3,
                UserId = "user-0004",
            },
        }
    );
    var item = await result.ModelAsync();
    var domain = gs2.Matchmaking.Namespace(
        namespaceName: "namespace-0001"
    );
    var future = domain.VoteMultiple(
        signedBallots: new Gs2.Unity.Gs2Matchmaking.Model.EzSignedBallot[] {
            new Gs2.Unity.Gs2Matchmaking.Model.EzSignedBallot
            {
                Body = "aaa",
                Signature = "bbb",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzSignedBallot
            {
                Body = "aaa",
                Signature = "bbb",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzSignedBallot
            {
                Body = "aaa",
                Signature = "bbb",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzSignedBallot
            {
                Body = "aaa",
                Signature = "bbb",
            },
        },
        gameResults: new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult[] {
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 1,
                UserId = "user-0001",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 2,
                UserId = "user-0002",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 2,
                UserId = "user-0003",
            },
            new Gs2.Unity.Gs2Matchmaking.Model.EzGameResult
            {
                Rank = 3,
                UserId = "user-0004",
            },
        }
    );
    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->Matchmaking->Namespace(
        "namespace-0001" // namespaceName
    );
    const auto Future = Domain->VoteMultiple(
        []
        {
            const auto v = MakeShared<TArray<TSharedPtr<Gs2::Matchmaking::Model::FSignedBallot>>>();
            v->Add({'body': 'aaa', 'signature': 'bbb'});
            v->Add({'body': 'aaa', 'signature': 'bbb'});
            v->Add({'body': 'aaa', 'signature': 'bbb'});
            v->Add({'body': 'aaa', 'signature': 'bbb'});
            return v;
        }(), // signedBallots
        []
        {
            const auto v = MakeShared<TArray<TSharedPtr<Gs2::Matchmaking::Model::FGameResult>>>();
            v->Add({'rank': 1, 'userId': 'user-0001'});
            v->Add({'rank': 2, 'userId': 'user-0002'});
            v->Add({'rank': 2, 'userId': 'user-0003'});
            v->Add({'rank': 3, 'userId': 'user-0004'});
            return v;
        }() // gameResults
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }

    // obtain changed values / result values
    const auto Future2 = Future->GetTask().Result()->Model();
    Future2->StartSynchronousTask();
    if (!TestFalse(WHAT, Future2->GetTask().IsError())) return false;
    const auto Result = Future2->GetTask().Result();

イベントハンドラ

OnJoinNotification

ギャザリングに新しい参加者が参加したときに使用する通知

名前説明
namespaceNamestringネームスペース名
gatheringNamestringギャザリング名
joinUserIdstringユーザーID

実装例

    gs2.Matchmaking.OnJoinNotification += notification =>
    {
        var namespaceName = notification.NamespaceName;
        var gatheringName = notification.GatheringName;
        var joinUserId = notification.JoinUserId;
    };
    gs2.Matchmaking.OnJoinNotification += notification =>
    {
        var namespaceName = notification.NamespaceName;
        var gatheringName = notification.GatheringName;
        var joinUserId = notification.JoinUserId;
    };
    Gs2->Matchmaking->OnJoinNotification().AddLambda([](const auto Notification)
    {
        const auto NamespaceName = Notification->NamespaceNameValue;
        const auto GatheringName = Notification->GatheringNameValue;
        const auto JoinUserId = Notification->JoinUserIdValue;
    });

OnLeaveNotification

ギャザリングから参加者が離脱したときに使用する通知

名前説明
namespaceNamestringネームスペース名
gatheringNamestringギャザリング名
leaveUserIdstringユーザーID

実装例

    gs2.Matchmaking.OnLeaveNotification += notification =>
    {
        var namespaceName = notification.NamespaceName;
        var gatheringName = notification.GatheringName;
        var leaveUserId = notification.LeaveUserId;
    };
    gs2.Matchmaking.OnLeaveNotification += notification =>
    {
        var namespaceName = notification.NamespaceName;
        var gatheringName = notification.GatheringName;
        var leaveUserId = notification.LeaveUserId;
    };
    Gs2->Matchmaking->OnLeaveNotification().AddLambda([](const auto Notification)
    {
        const auto NamespaceName = Notification->NamespaceNameValue;
        const auto GatheringName = Notification->GatheringNameValue;
        const auto LeaveUserId = Notification->LeaveUserIdValue;
    });

OnCompleteNotification

マッチメイキングが成立したときに使用する通知

名前説明
namespaceNamestringネームスペース名
gatheringNamestringギャザリング名

実装例

    gs2.Matchmaking.OnCompleteNotification += notification =>
    {
        var namespaceName = notification.NamespaceName;
        var gatheringName = notification.GatheringName;
    };
    gs2.Matchmaking.OnCompleteNotification += notification =>
    {
        var namespaceName = notification.NamespaceName;
        var gatheringName = notification.GatheringName;
    };
    Gs2->Matchmaking->OnCompleteNotification().AddLambda([](const auto Notification)
    {
        const auto NamespaceName = Notification->NamespaceNameValue;
        const auto GatheringName = Notification->GatheringNameValue;
    });

OnChangeRatingNotification

レーティング値が変動したときに使用する通知

名前説明
namespaceNamestringネームスペース名
rateValuefloat

実装例

    gs2.Matchmaking.OnChangeRatingNotification += notification =>
    {
        var namespaceName = notification.NamespaceName;
        var rateValue = notification.RateValue;
    };
    gs2.Matchmaking.OnChangeRatingNotification += notification =>
    {
        var namespaceName = notification.NamespaceName;
        var rateValue = notification.RateValue;
    };
    Gs2->Matchmaking->OnChangeRatingNotification().AddLambda([](const auto Notification)
    {
        const auto NamespaceName = Notification->NamespaceNameValue;
        const auto RateValue = Notification->RateValueValue;
    });