GS2-Matchmaking SDK for Game Engine API リファレンス
モデル
EzGathering
ギャザリング
マッチメイキングによって集められたゲームプレイヤーグループを表すエンティティです。
マッチメイキング用のパラメータを複数持っており、パラメータを総合的に判断してプレイヤーをグルーピングします。
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
gatheringId | string | ✓ | | ~ 1024文字 | ギャザリングGRN |
name | string | ✓ | UUID | ~ 128文字 | ギャザリング名 |
attributeRanges | List<EzAttributeRange> | | [] | | 募集条件 |
capacityOfRoles | List<EzCapacityOfRole> | ✓ | [] | | 募集枠 |
allowUserIds | List<string> | | [] | | 参加を許可するユーザ |
metadata | string | | | ~ 1024文字 | メタデータ |
expiresAt | long | | | | ギャザリングの有効期限 |
createdAt | long | ✓ | | | 作成日時 |
updatedAt | long | ✓ | | | 最終更新日時 |
EzRatingModel
レーティングモデル
GS2 ではレーティングアルゴリズムとして Glicko-2 を採用しています。
Glicko-2 には複数のパラメータがありますが、GS2-Matchmaking ではそれらを総合的に表す ボラティリティ という1つのパラメータに集約しています。
ボラティリティ は変化の大きさを表すパラメータで、値が大きいほどレーティングの値の変動量が大きくなります。
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
name | string | ✓ | | ~ 128文字 | レーティングモデル名 |
metadata | string | | | ~ 128文字 | メタデータ |
volatility | int | ✓ | 100 | 1 ~ 350 | レート値の変動の大きさ |
EzAttributeRange
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
name | string | ✓ | | ~ 128文字 | 属性名 |
min | int | ✓ | 0 | ~ 2147483646 | ギャザリング参加可能な属性値の最小値 |
max | int | ✓ | 0 | ~ 2147483646 | ギャザリング参加可能な属性値の最大値 |
EzCapacityOfRole
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
roleName | string | ✓ | “default” | ~ 128文字 | ロール名 |
roleAliases | List<string> | | [] | | ロール名の別名リスト |
capacity | int | ✓ | | 1 ~ 256 | 募集人数 |
participants | List<EzPlayer> | | [] | | 参加者のプレイヤー情報リスト |
EzAttribute
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
name | string | ✓ | | ~ 128文字 | 属性名 |
value | int | ✓ | 0 | ~ 2147483646 | 属性値 |
EzPlayer
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
userId | string | ✓ | | ~ 128文字 | ユーザーID |
attributes | List<EzAttribute> | | [] | | 属性値のリスト |
roleName | string | ✓ | “default” | ~ 128文字 | ロール名 |
denyUserIds | List<string> | | [] | | 参加を拒否するユーザIDリスト |
EzRating
レーティング
ゲームプレイヤー毎の現在のレーティングの値を保持するエンティティです。
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
ratingId | string | ✓ | | ~ 1024文字 | レーティングGRN |
name | string | ✓ | | ~ 128文字 | レーティング名 |
userId | string | ✓ | | ~ 128文字 | ユーザーID |
rateValue | float | ✓ | 1500.0 | ~ 65535.0 | |
createdAt | long | ✓ | | | 作成日時 |
updatedAt | long | ✓ | | | 最終更新日時 |
EzGameResult
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
rank | int | ✓ | | ~ 2147483646 | 順位 |
userId | string | ✓ | | ~ 128文字 | ユーザーID |
EzBallot
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
userId | string | ✓ | | ~ 128文字 | ユーザーID |
ratingName | string | ✓ | | ~ 128文字 | レーティング計算に使用するレーティング名 |
gatheringName | string | ✓ | | ~ 128文字 | 投票対象のギャザリング名 |
numberOfPlayer | int | ✓ | | 2 ~ 10 | 参加人数 |
EzSignedBallot
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
body | string | ✓ | | ~ 1024文字 | 投票用紙の署名対象のデータ |
signature | string | ✓ | | ~ 256文字 | 投票用紙の署名 |
EzTimeSpan
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
days | int | ✓ | 0 | ~ 365 | 現在時刻からの日数 |
hours | int | ✓ | 0 | ~ 24 | 現在時刻からの時間 |
minutes | int | ✓ | 0 | ~ 60 | 現在時刻からの分 |
メソッド
cancelMatchmaking
マッチメイキングをキャンセルし、参加中のギャザリングから離脱。
ギャザリングから離脱する前にマッチメイキングが完了した場合は、NotFoundException(404エラー) が発生し失敗します。
Request
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
namespaceName | string | ✓ | | ~ 32文字 | ネームスペース名 |
gatheringName | string | ✓ | UUID | ~ 128文字 | ギャザリング名 |
accessToken | string | ✓ | | ~ 128文字 | ユーザーID |
Result
実装例
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
Result
実装例
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
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
namespaceName | string | ✓ | | ~ 32文字 | ネームスペース名 |
accessToken | string | ✓ | | ~ 128文字 | ユーザーID |
player | EzPlayer | ✓ | | | 自身のプレイヤー情報 |
matchmakingContextToken | string | | | ~ 5120文字 | 検索の再開に使用する マッチメイキングの状態を保持するトークン |
Result
| 型 | 説明 |
---|
item | EzGathering | 参加したギャザリング |
matchmakingContextToken | string | マッチメイキングの状態を保持するトークン |
実装例
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
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
namespaceName | string | ✓ | | ~ 32文字 | ネームスペース名 |
gatheringName | string | ✓ | UUID | ~ 128文字 | ギャザリング名 |
Result
実装例
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
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
namespaceName | string | ✓ | | ~ 32文字 | ネームスペース名 |
gatheringName | string | ✓ | UUID | ~ 128文字 | ギャザリング名 |
accessToken | string | ✓ | | ~ 128文字 | ユーザーID |
attributeRanges | List<EzAttributeRange> | | [] | | 募集条件 |
Result
実装例
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
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
namespaceName | string | ✓ | | ~ 32文字 | ネームスペース名 |
ratingName | string | ✓ | | ~ 128文字 | レーティングモデル名 |
Result
実装例
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
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
namespaceName | string | ✓ | | ~ 32文字 | ネームスペース名 |
Result
実装例
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
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
namespaceName | string | ✓ | | ~ 32文字 | ネームスペース名 |
accessToken | string | ✓ | | ~ 128文字 | ユーザーID |
ratingName | string | ✓ | | ~ 128文字 | レーティング名 |
Result
実装例
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
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
namespaceName | string | ✓ | | ~ 32文字 | ネームスペース名 |
accessToken | string | ✓ | | ~ 128文字 | ユーザーID |
pageToken | string | | | ~ 1024文字 | データの取得を開始する位置を指定するトークン |
limit | int | ✓ | 30 | 1 ~ 1000 | データの取得件数 |
Result
| 型 | 説明 |
---|
items | List<EzRating> | レーティングのリスト |
nextPageToken | string | リストの続きを取得するためのページトークン |
実装例
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
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
namespaceName | string | ✓ | | ~ 32文字 | ネームスペース名 |
ratingName | string | ✓ | | ~ 128文字 | レーティング名 |
gatheringName | string | ✓ | | ~ 128文字 | 投票対象のギャザリング名 |
accessToken | string | ✓ | | ~ 128文字 | ユーザーID |
Result
| 型 | 説明 |
---|
item | EzBallot | 投票用紙 |
body | string | 署名対象のデータ |
signature | string | 署名データ |
実装例
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
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
namespaceName | string | ✓ | | ~ 32文字 | ネームスペース名 |
ballotBody | string | ✓ | | ~ 1024文字 | 投票用紙の署名対象のデータ |
ballotSignature | string | ✓ | | ~ 256文字 | 投票用紙の署名 |
gameResults | List<EzGameResult> | | | | 投票内容。対戦を行ったプレイヤーグループ1に所属するユーザIDのリスト |
Result
実装例
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
Result
実装例
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
ギャザリングに新しい参加者が参加したときに使用する通知
名前 | 型 | 説明 |
---|
namespaceName | string | ネームスペース名 |
gatheringName | string | ギャザリング名 |
joinUserId | string | ユーザー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
ギャザリングから参加者が離脱したときに使用する通知
名前 | 型 | 説明 |
---|
namespaceName | string | ネームスペース名 |
gatheringName | string | ギャザリング名 |
leaveUserId | string | ユーザー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
マッチメイキングが成立したときに使用する通知
名前 | 型 | 説明 |
---|
namespaceName | string | ネームスペース名 |
gatheringName | string | ギャザリング名 |
実装例
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
レーティング値が変動したときに使用する通知
名前 | 型 | 説明 |
---|
namespaceName | string | ネームスペース名 |
rateValue | float | |
実装例
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;
});