Interface ITurnBasedMultiplayerClient
Turn-Based Multiplayer API.
Namespace: EasyMobile
Assembly: cs.temp.dll.dll
Syntax
public interface ITurnBasedMultiplayerClient
Methods
AcceptInvitation(Invitation, Action<Boolean, TurnBasedMatch>)
Accepts a turn-based match invitation.
Declaration
void AcceptInvitation(Invitation invitation, Action<bool, TurnBasedMatch> callback)
Parameters
Type | Name | Description |
---|---|---|
Invitation | invitation | Invitation to accept. |
System.Action<System.Boolean, TurnBasedMatch> | callback | Called when match setup is complete or fails. If it succeeds, this callback will be called with (true, match); otherwise, the callback will be called with (false, null). This callback is always invoked on the main thread. |
AcknowledgeFinished(TurnBasedMatch, Action<Boolean>)
Acknowledges that a turn-based match was finished.
Declaration
void AcknowledgeFinished(TurnBasedMatch match, Action<bool> callback)
Parameters
Type | Name | Description |
---|---|---|
TurnBasedMatch | match | The finished turn-based match. |
System.Action<System.Boolean> | callback | Callback. Will be called with true for success, false for failure. This callback is always called on the main thread. |
Remarks
Call this on a finished match that you have just shown to the user, to acknowledge that the user has seen the results of the finished match. This will remove the match from the user's matches UI.
CreateQuickMatch(MatchRequest, Action<Boolean, TurnBasedMatch>)
Creates a turn-based match with randomly selected opponent(s). No UI will be shown.
Declaration
void CreateQuickMatch(MatchRequest request, Action<bool, TurnBasedMatch> callback)
Parameters
Type | Name | Description |
---|---|---|
MatchRequest | request | The match request. |
System.Action<System.Boolean, TurnBasedMatch> | callback | Called when match setup is complete or fails. If it succeeds, this callback will be called with (true, match); otherwise, the callback will be called with (false, null). This callback is always invoked on the main thread. |
CreateWithMatchmakerUI(MatchRequest, Action, Action<String>)
Creates a turn-based match with the standard matchmaker UI where the initiating player can invite friends, nearby players or pick random opponents to join the match.
Declaration
void CreateWithMatchmakerUI(MatchRequest request, Action cancelCallback, Action<string> errorCallback)
Parameters
Type | Name | Description |
---|---|---|
MatchRequest | request | Request. |
System.Action | cancelCallback | Cancel callback, called when the UI is closed. |
System.Action<System.String> | errorCallback | Error callback, called when the UI encounters some error. |
DeclineInvitation(Invitation)
Declines a turn-based match invitation.
Declaration
void DeclineInvitation(Invitation invitation)
Parameters
Type | Name | Description |
---|---|---|
Invitation | invitation | Invitation to decline. |
Finish(TurnBasedMatch, Byte[], MatchOutcome, Action<Boolean>)
Finishes a turn-based match.
Declaration
void Finish(TurnBasedMatch match, byte[] data, MatchOutcome outcome, Action<bool> callback)
Parameters
Type | Name | Description |
---|---|---|
TurnBasedMatch | match | The turn-based match to finish. |
System.Byte[] | data | Final match data. |
MatchOutcome | outcome | The outcome of the match (who won, who lost, ...) |
System.Action<System.Boolean> | callback | Callback. Will be called with true for success, false for failure. This callback is always called on the main thread. |
GetAllMatches(Action<TurnBasedMatch[]>)
Gets all turn-based matches that the local player joins.
Declaration
void GetAllMatches(Action<TurnBasedMatch[]> callback)
Parameters
Type | Name | Description |
---|---|---|
System.Action<TurnBasedMatch[]> | callback | Callback. |
GetMaxMatchDataSize()
Gets the maximum size allowed for the match data, in bytes.
Declaration
int GetMaxMatchDataSize()
Returns
Type | Description |
---|---|
System.Int32 | The maximum match data size in bytes. |
LeaveMatch(TurnBasedMatch, Action<Boolean>)
Leaves a turn-based match (not during turn). Call this to leave the match when it is not your turn.
Declaration
void LeaveMatch(TurnBasedMatch match, Action<bool> callback)
Parameters
Type | Name | Description |
---|---|---|
TurnBasedMatch | match | Match. |
System.Action<System.Boolean> | callback | Callback. Will be called with true for success, false for failure. This callback is always called on the main thread. |
LeaveMatchInTurn(TurnBasedMatch, Participant, Action<Boolean>)
Leaves a turn-based match (during turn). Call this to leave the match when it's your turn.
Declaration
void LeaveMatchInTurn(TurnBasedMatch match, Participant nextParticipant, Action<bool> callback)
Parameters
Type | Name | Description |
---|---|---|
TurnBasedMatch | match | The turn-based match to leave. |
Participant | nextParticipant | The participant to take the next turn. If this is null and there are automatch slots open, the turn will be passed to one of the automatch players. Passing null when there are no open automatch slots is an error. |
System.Action<System.Boolean> | callback | Callback. Will be called with true for success, false for failure. This callback is always called on the main thread. |
LeaveMatchInTurn(TurnBasedMatch, String, Action<Boolean>)
Leaves a turn-based match (during turn). Call this to leave the match when it's your turn.
Declaration
void LeaveMatchInTurn(TurnBasedMatch match, string nextParticipantId, Action<bool> callback)
Parameters
Type | Name | Description |
---|---|---|
TurnBasedMatch | match | The turn-based match to leave. |
System.String | nextParticipantId | ID of the participant to take the next turn. If this is null or empty and there are automatch slots open, the turn will be passed to one of the automatch players. Passing null or empty when there are no open automatch slots is an error. |
System.Action<System.Boolean> | callback | Callback. Will be called with true for success, false for failure. This callback is always called on the main thread. |
RegisterMatchDelegate(MatchDelegate)
Registers a delegate to be called when a turn-based match arrives.
Declaration
void RegisterMatchDelegate(MatchDelegate del)
Parameters
Type | Name | Description |
---|---|---|
MatchDelegate | del | Delegate to notify when a match arrives. Always called on the main thread |
Remarks
Matches may arrive as notifications on the device when it's the player's turn. If the match arrived via notification (this can be determined from the delegate's parameters), the recommended implementation is to take the player directly to the game screen so they can play their turn.
Rematch(TurnBasedMatch, Action<Boolean, TurnBasedMatch>)
Requests a rematch. This can be used on a finished match in order to start a new match with the same opponents.
Declaration
void Rematch(TurnBasedMatch match, Action<bool, TurnBasedMatch> callback)
Parameters
Type | Name | Description |
---|---|---|
TurnBasedMatch | match | The turn-based match to replay. |
System.Action<System.Boolean, TurnBasedMatch> | callback | Called when the new match setup is complete or fails. If it succeeds, this callback will be called with (true, match); otherwise, the callback will be called with (false, null). This callback is always invoked on the main thread. |
ShowMatchesUI()
Shows the standard UI where the player can pick a turn-based match or accept an invitation.
Declaration
void ShowMatchesUI()
TakeTurn(TurnBasedMatch, Byte[], Participant, Action<Boolean>)
Takes a turn.
Declaration
void TakeTurn(TurnBasedMatch match, byte[] data, Participant nextParticipant, Action<bool> callback)
Parameters
Type | Name | Description |
---|---|---|
TurnBasedMatch | match | The turn-based match to take turn in. |
System.Byte[] | data | Data. New match data. |
Participant | nextParticipant | The participant to take the next turn. If this is null and there are automatch slots open, the turn will be passed to one of the automatch players. Passing null when there are no open automatch slots is an error. |
System.Action<System.Boolean> | callback | Callback. Will be called with true for success, false for failure. This callback is always called on the main thread. |
Remarks
Before you call this method, make sure that it is actually the player's turn in the match, otherwise this call will fail.
TakeTurn(TurnBasedMatch, Byte[], String, Action<Boolean>)
Takes a turn.
Declaration
void TakeTurn(TurnBasedMatch match, byte[] data, string nextParticipantId, Action<bool> callback)
Parameters
Type | Name | Description |
---|---|---|
TurnBasedMatch | match | The turn-based match to take turn in. |
System.Byte[] | data | Data. New match data. |
System.String | nextParticipantId | ID of the participant to take the next turn. If this is null or empty and there are automatch slots open, the turn will be passed to one of the automatch players. Passing null or empty when there are no open automatch slots is an error. |
System.Action<System.Boolean> | callback | Callback. Will be called with true for success, false for failure. This callback is always called on the main thread. |
Remarks
Before you call this method, make sure that it is actually the player's turn in the match, otherwise this call will fail.