Quantum 3
3.1.0
Extensions methods to wrap Photon Realtime API calls into System.Threading.Tasks. More...
Static Public Member Functions | |
| static Task< RegionHandler > | ConnectToNameserverAndWaitForRegionsAsync (this RealtimeClient client, AppSettings appSettings, bool pingRegions=true, AsyncConfig config=null) |
| Connect to the name server and wait until ping results are available. Will work when client is already connected or connecting to nameserver. Will fail when connected to another server type. The client connection will be disconnected AFTER returning the result. It's not supposed to be useable. More... | |
| static Task | ConnectUsingSettingsAsync (this RealtimeClient client, AppSettings appSettings, AsyncConfig config=null) |
| Connect to master server. More... | |
| static Task< short > | CreateAndJoinRoomAsync (this RealtimeClient client, EnterRoomArgs enterRoomArgs, bool throwOnError=true, AsyncConfig config=null) |
| Create and join a room. More... | |
| static AsyncOperationHandler | CreateConnectionHandler (this RealtimeClient client, bool throwOnErrors=true, AsyncConfig config=null) |
| Create a AsyncOperationHandler instance, sets up the Photon callbacks, schedules removing them, create a connection service task. The handler will monitor the Photon callbacks and complete, fault accordingly. AsyncOperationHandler.Task can complete with ErrorCode.Ok, exception on errors and a timeout OperationTimeoutException. More... | |
| static void | CreateServiceTask (this RealtimeClient client, CancellationToken token, TaskCompletionSource< short > completionSource=null, IDisposable disposable=null, AsyncConfig config=null) |
| Starts a task that calls RealtimeClient.Service() every updateIntervalMs milliseconds. The task is stopped by the cancellation token from AsyncOperationHandler.Token. It will set an exception on the AsyncOperationHandler TaskCompletionSource if after the timeout it is still not completed. More... | |
| static Task | DisconnectAsync (this RealtimeClient client, AsyncConfig config=null) |
| Disconnects the client. More... | |
| static Task< short > | JoinLobbyAsync (this RealtimeClient client, TypedLobby lobby=null, bool throwOnError=true, AsyncConfig config=null) |
| Join a Lobby More... | |
| static Task< short > | JoinOrCreateRoomAsync (this RealtimeClient client, EnterRoomArgs enterRoomArgs, bool throwOnError=true, AsyncConfig config=null) |
| Join or create room. More... | |
| static Task< short > | JoinRandomOrCreateRoomAsync (this RealtimeClient client, JoinRandomRoomArgs joinRandomRoomParams=null, EnterRoomArgs enterRoomArgs=null, bool throwOnError=true, AsyncConfig config=null) |
| Join random or create room More... | |
| static Task< short > | JoinRandomRoomAsync (this RealtimeClient client, JoinRandomRoomArgs joinRandomRoomParams=null, bool throwOnError=true, AsyncConfig config=null) |
| Join random room More... | |
| static Task< short > | JoinRoomAsync (this RealtimeClient client, EnterRoomArgs enterRoomArgs, bool throwOnError=true, AsyncConfig config=null) |
| Join room. More... | |
| static Task< short > | LeaveLobbyAsync (this RealtimeClient client, bool throwOnError=true, AsyncConfig config=null) |
| Leave a Lobby More... | |
| static Task | LeaveRoomAsync (this RealtimeClient client, bool becomeInactive=false, bool throwOnError=true, AsyncConfig config=null) |
| Leave room More... | |
| static Task< short > | ReconnectAndRejoinAsync (this RealtimeClient client, bool throwOnError=true, AsyncConfig config=null) |
| static Task< short > | ReconnectAndRejoinAsync (this RealtimeClient client, object ticket=null, bool throwOnError=true, AsyncConfig config=null) |
| Runs reconnect and rejoin. More... | |
| static Task | ReconnectToMasterAsync (this RealtimeClient client, AsyncConfig config=null) |
| Reconnect to master server, re-using the existing authentication token (RealtimeClient.AuthValues). More... | |
| static Task< short > | RejoinRoomAsync (this RealtimeClient client, string roomName, object ticket=null, bool throwOnError=true, AsyncConfig config=null) |
| Rejoin room. More... | |
| static Task | WaitForDisconnect (this RealtimeClient client, AsyncConfig config=null) |
| Returns a task that is completed when the connection disconnects. This does not create a service handler not does the task timeout. More... | |
Extensions methods to wrap Photon Realtime API calls into System.Threading.Tasks.
|
inlinestatic |
Connect to master server.
| client | Client. |
| appSettings | App settings. |
| config | Optional AsyncConfig, otherwise AsyncConfig.Global is used. |
| DisconnectException | Is thrown when the connection is terminated. |
| AuthenticationFailedException | Is thrown when the authentication failed. |
| OperationStartException | Is thrown when the operation could not be started. |
| OperationException | Is thrown when the operation completed unsuccessfully. |
| OperationTimeoutException | Is thrown when the operation timed out. |
| OperationCanceledException | Is thrown when the operation have been canceled (AsyncConfig.CancellationSource). |
|
inlinestatic |
Runs reconnect and rejoin.
| client | Client object should be in Disconnected state. |
| ticket | Optional Matchmaking Ticket. |
| throwOnError | Set ErrorCode as result on RoomJoinFailed. |
| config | Optional AsyncConfig, otherwise AsyncConfig.Global is used. |
| DisconnectException | Is thrown when the connection terminated. |
| OperationStartException | Is thrown when the operation could not be started. |
| OperationException | Is thrown when the operation completed unsuccessfully. |
| OperationTimeoutException | Is thrown when the operation timed out. |
| OperationCanceledException | Is thrown when the operation have been canceled (AsyncConfig.CancellationSource). |
|
inlinestatic |
Reconnect to master server, re-using the existing authentication token (RealtimeClient.AuthValues).
Authentication errors are not signalled as AuthenticationFailedException here (unlike ConnectUsingSettingsAsync). The server rejects the token with an error response and the client disconnects, so an expired or invalid token arrives as a DisconnectException. Check its DisconnectException.Cause for DisconnectCause.AuthenticationTicketExpired, DisconnectCause.InvalidAuthentication or DisconnectCause.CustomAuthenticationFailed to tell an auth failure apart from a network drop. Recovering from those means setting fresh RealtimeClient.AuthValues and running a full ConnectUsingSettingsAsync.
RealtimeClient.ReconnectToMaster only checks that a token is present, not whether it expired.
| client | Client object should be in Disconnected state. |
| config | Optional AsyncConfig, otherwise AsyncConfig.Global is used. |
| DisconnectException | Is thrown when the connection terminated, including when the token was rejected (see remarks). |
| OperationStartException | Is thrown when the operation could not be started (client still connected, no known Master Server address or no token). |
| OperationTimeoutException | Is thrown when the operation timed out. |
| OperationCanceledException | Is thrown when the operation have been canceled (AsyncConfig.CancellationSource). |
|
inlinestatic |
Disconnects the client.
| client | Client. |
| config | Optional AsyncConfig, otherwise AsyncConfig.Global is used. |
| DisconnectException | Is thrown when the connection terminated. |
| OperationStartException | Is thrown when the operation could not be started. |
| OperationException | Is thrown when the operation completed unsuccessfully. |
| OperationTimeoutException | Is thrown when the operation timed out. |
| OperationCanceledException | Is thrown when the operation have been canceled (AsyncConfig.CancellationSource). |
|
inlinestatic |
Connect to the name server and wait until ping results are available. Will work when client is already connected or connecting to nameserver. Will fail when connected to another server type. The client connection will be disconnected AFTER returning the result. It's not supposed to be useable.
A client that is already connected to the Name Server gets sent an OpGetRegions by this method. A client that is still connecting to it sends that operation by itself, unless its AppSettings.FixedRegion is set. That case can not produce a region list, so it fails with an OperationStartException right away (disconnect the client first).
| client | Client object. |
| appSettings | Photon AppSettings, only uses AppId. |
| pingRegions | Ping each region, takes longer to complete. |
| config | Async config. |
| DisconnectException | Is thrown when the connection terminated. |
| OperationStartException | Is thrown when the operation could not be started. |
| OperationException | Is thrown when the operation completed unsuccessfully. |
| OperationTimeoutException | Is thrown when the operation timed out. |
| OperationCanceledException | Is thrown when the operation have been canceled (AsyncConfig.CancellationSource). |
|
inlinestatic |
Create and join a room.
The lobby is only left when the client leaves the Master Server to enter a room on a Game Server (InLobby becomes false). A failure on the Master Server keeps the client in the lobby. The lobby is never re-joined automatically. When the entry fails on the Game Server, the client returns to the Master Server before this task completes, so JoinLobbyAsync can be called right after it.
| client | Client object. |
| enterRoomArgs | Enter room params. |
| throwOnError | Set ErrorCode as result on RoomCreateFailed or RoomJoinFailed. |
| config | Optional AsyncConfig, otherwise AsyncConfig.Global is used. |
| DisconnectException | Is thrown when the connection terminated. |
| OperationStartException | Is thrown when the operation could not be started. |
| OperationException | Is thrown when the operation completed unsuccessfully. |
| OperationTimeoutException | Is thrown when the operation timed out. |
| OperationCanceledException | Is thrown when the operation have been canceled (AsyncConfig.CancellationSource). |
|
inlinestatic |
Join room.
The lobby is only left when the client leaves the Master Server to enter a room on a Game Server (InLobby becomes false). A failure on the Master Server keeps the client in the lobby. The lobby is never re-joined automatically. When the entry fails on the Game Server, the client returns to the Master Server before this task completes, so JoinLobbyAsync can be called right after it.
| client | Client object. |
| enterRoomArgs | Enter room params. |
| throwOnError | Set ErrorCode as result when JoinRoomFailed. |
| config | Optional AsyncConfig, otherwise AsyncConfig.Global is used. |
| DisconnectException | Is thrown when the connection terminated. |
| OperationStartException | Is thrown when the operation could not be started. |
| OperationException | Is thrown when the operation completed unsuccessfully. |
| OperationTimeoutException | Is thrown when the operation timed out. |
| OperationCanceledException | Is thrown when the operation have been canceled (AsyncConfig.CancellationSource). |
|
inlinestatic |
Rejoin room.
The lobby is only left when the client leaves the Master Server to enter a room on a Game Server (InLobby becomes false). A failure on the Master Server keeps the client in the lobby. The lobby is never re-joined automatically. When the entry fails on the Game Server, the client returns to the Master Server before this task completes, so JoinLobbyAsync can be called right after it.
| client | Client object. |
| roomName | Room name to rejoin. |
| ticket | Matchmaking Ticket for this user and room. Can be null if not used. |
| throwOnError | Set ErrorCode as result when JoinRoomFailed. |
| config | Optional AsyncConfig, otherwise AsyncConfig.Global is used. |
| DisconnectException | Is thrown when the connection terminated. |
| OperationStartException | Is thrown when the operation could not be started. |
| OperationException | Is thrown when the operation completed unsuccessfully. |
| OperationTimeoutException | Is thrown when the operation timed out. |
| OperationCanceledException | Is thrown when the operation have been canceled (AsyncConfig.CancellationSource). |
|
inlinestatic |
Join or create room.
The lobby is only left when the client leaves the Master Server to enter a room on a Game Server (InLobby becomes false). A failure on the Master Server keeps the client in the lobby. The lobby is never re-joined automatically. When the entry fails on the Game Server, the client returns to the Master Server before this task completes, so JoinLobbyAsync can be called right after it.
| client | Client object. |
| enterRoomArgs | Enter room params. |
| throwOnError | Set ErrorCode as result when JoinRoomFailed. |
| config | Optional AsyncConfig, otherwise AsyncConfig.Global is used. |
| DisconnectException | Is thrown when the connection terminated. |
| OperationStartException | Is thrown when the operation could not be started. |
| OperationException | Is thrown when the operation completed unsuccessfully. |
| OperationTimeoutException | Is thrown when the operation timed out. |
| OperationCanceledException | Is thrown when the operation have been canceled (AsyncConfig.CancellationSource). |
|
inlinestatic |
Join random or create room
The lobby is only left when the client leaves the Master Server to enter a room on a Game Server (InLobby becomes false). A failure on the Master Server keeps the client in the lobby. The lobby is never re-joined automatically. When the entry fails on the Game Server, the client returns to the Master Server before this task completes, so JoinLobbyAsync can be called right after it.
| client | Client object. |
| joinRandomRoomParams | Join random room params. |
| enterRoomArgs | Enter room params. |
| throwOnError | Set ErrorCode as result when operation fails with ErrorCode. |
| config | Optional AsyncConfig, otherwise AsyncConfig.Global is used. |
| DisconnectException | Is thrown when the connection terminated. |
| OperationStartException | Is thrown when the operation could not be started. |
| OperationException | Is thrown when the operation completed unsuccessfully. |
| OperationTimeoutException | Is thrown when the operation timed out. |
| OperationCanceledException | Is thrown when the operation have been canceled (AsyncConfig.CancellationSource). |
|
inlinestatic |
Join random room
The lobby is only left when the client leaves the Master Server to enter a room on a Game Server (InLobby becomes false). A failure on the Master Server keeps the client in the lobby. The lobby is never re-joined automatically. When the entry fails on the Game Server, the client returns to the Master Server before this task completes, so JoinLobbyAsync can be called right after it.
| client | Client object. |
| joinRandomRoomParams | Join random room params. |
| throwOnError | Set ErrorCode as result when operation fails with ErrorCode. |
| config | Optional AsyncConfig, otherwise AsyncConfig.Global is used. |
| DisconnectException | Is thrown when the connection terminated. |
| OperationStartException | Is thrown when the operation could not be started. |
| OperationException | Is thrown when the operation completed unsuccessfully. |
| OperationTimeoutException | Is thrown when the operation timed out. |
| OperationCanceledException | Is thrown when the operation have been canceled (AsyncConfig.CancellationSource). |
|
inlinestatic |
Leave room
The task completes when the client is back on the Master Server. The lobby the client was in before it entered the room is not re-joined automatically (InLobby is false): call JoinLobbyAsync if needed.
| client | Client object. |
| becomeInactive | If true, this player becomes inactive in the game and can return later (if PlayerTTL of the room is != 0). |
| throwOnError | Set ErrorCode as result when operation fails with ErrorCode. |
| config | Optional AsyncConfig, otherwise AsyncConfig.Global is used. |
| DisconnectException | Is thrown when the connection terminated. |
| OperationStartException | Is thrown when the operation could not be started. |
| OperationException | Is thrown when the operation completed unsuccessfully. |
| OperationTimeoutException | Is thrown when the operation timed out. |
| OperationCanceledException | Is thrown when the operation have been canceled (AsyncConfig.CancellationSource). |
|
inlinestatic |
Join a Lobby
| client | Client object. |
| lobby | Lobby to Join. |
| throwOnError | Set ErrorCode as result when operation fails with ErrorCode. |
| config | Optional AsyncConfig, otherwise AsyncConfig.Global is used. |
|
inlinestatic |
Leave a Lobby
| client | Client object. |
| throwOnError | Set ErrorCode as result when operation fails with ErrorCode. |
| config | Optional AsyncConfig, otherwise AsyncConfig.Global is used. |
|
inlinestatic |
Create a AsyncOperationHandler instance, sets up the Photon callbacks, schedules removing them, create a connection service task. The handler will monitor the Photon callbacks and complete, fault accordingly. AsyncOperationHandler.Task can complete with ErrorCode.Ok, exception on errors and a timeout OperationTimeoutException.
| client | Client. |
| throwOnErrors | The default implementation will throw an exception on every unexpected result, set this to false to return a result ErrorCode instead. |
| config | Optional AsyncConfig, otherwise AsyncConfig.Global is used. |
|
inlinestatic |
Starts a task that calls RealtimeClient.Service() every updateIntervalMs milliseconds. The task is stopped by the cancellation token from AsyncOperationHandler.Token. It will set an exception on the AsyncOperationHandler TaskCompletionSource if after the timeout it is still not completed.
| client | Client. |
| token | Cancellation token to stop the update loop. |
| completionSource | Completion source is notified on an exception in Service(). |
| disposable | OperationHandler requires disposing. |
| config | Optional AsyncConfig, otherwise AsyncConfig.Global is used. |
|
inlinestatic |
Returns a task that is completed when the connection disconnects. This does not create a service handler not does the task timeout.
| client | Client object. |
| config | Async config. |
| OperationCanceledException | Is thrown when the operation have been canceled (AsyncConfig.CancellationSource). |