File size: 10,132 Bytes
d7bb13e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | 1.6 AsyncCommand .46
1.6.1 AsyncCommand.Cancel .46
1.6.2 AsyncCommand.Create .47
1.6.3 AsyncCommand.Execute .48
1.6.4 AsyncCommand.GetErrorCode .48
1.6.5 AsyncCommand.GetNpErrorCode .49
1.6.6 AsyncCommand.GetResultCount .50
1.6.7 AsyncCommand.GetResults .50
1.6.8 AsyncCommand.IsFinished .51
1.6.9 AsyncCommand.IsInProgress .52
1.6.10 AsyncCommand.Succeeded .52
1.7 AsyncContext .53
1.7.1 AsyncContext.Create .53
AsyncCommand
AsyncCommand.Cancel
Brief
Cancels an in progress command.
Definition
! boolean AsyncCommand.Cancel( AsyncCommand asyncCmd )
Arguments
asyncCmd - async command to cancel.
Return Values
It returns true if the command was successfully canceled and false otherwise.
Description
Cancels an executing command.
Examples
local result = AsyncCommand.Cancel( asyncCmd )
See Also
� AsyncCommand.Create
� AsyncCommand.Execute
AsyncCommand.Create
Brief
Create a new asynchronous command.
Definition
! AsyncCommand.Create(commandType, ...)
Arguments
commandType - a valid command type value. See specific AsyncCommand.Create functions for valid command types.
Return Values
AsyncCommand object on success, nil on failure.
Description
Creates a new asynchronous command with the specified parameters, if any. If nil is returned and there is no associated Lua error provided, then
this indicates that the specified command type is unavailable. If the command type is unavailable, the script should make no further attempts to
create it.
Examples
! ticketCmd = AsyncCommand.Create( AsyncCommands.TicketRequest )
See Also
AsyncCommand.Create
AsyncCommand.IsFinished
AsyncCommand.GetErrorCode
AsyncCommand. Execute
Brief
Marks an asynchronous command for execution.
Definition
boolean AsyncCommand.Execute( asyncCmd, ...)
boolean AsyncCommand.Execute( AsyncCommand command, string serviceld, MemoryContainer container )
Arguments
asyncCmd - command to executeserviceld - The service id to request a ticket forcontainer - The container to store the ticket in
Return Values
false if command could not be executed, true if command successfully marked for execution.
Description
Submits the command to be executed. Note that success does not indicate that the command has finished, nor that it must successfully complete,
rather that the command is in progress and will at some later stage either return successfully or with an error. The user should poll the command
for completion, either within a coroutine or the game update loop. For the period between executing the command and receiving the result, the
command is considered in progress. In this period the user can request cancellation of the command; this may or may not succeed depending on
the execution stage of the command, and so should not be relied upon explicitly. No upper time limit is provided for the completion of command
execution, nor are are any guarantees provided that commands will execute in the order they were submitted; in other words, a script should not
rely on either a specific execution time or order. If required, execution order can be implemented by the script by waiting for preceding commands
to finish before issuing dependent commands.
If Execute returns false, then this is most likely due to invalid or missing arguments passed to the function, and will be indicated by a Lua error -
check the documentation for the command. If there is no Lua error, then the command execution has failed due to the NP services system being
currently too busy to accept another command. In this case, wait some time and try to execute the command again, and repeat if necessary. This
situation should be rare and transient, and only occur under very high load.
Examples
local container = MemoryContainer.Create ( 1024 )
local ticketCmd = AsyncCommand.Create( AsyncCommands.TicketRequest )
AsyncCommand:Execute( ticketCmd, "XX1234-XXXX12345_00", container )
See Also
� AsyncCommand.Create
� AsyncCommand.IsFinished
� AsyncCommand.IsInProgress
� AsyncCommand.Cancel
AsyncCommand.GetErrorCode
Brief
Indicates the command result code if the command failed.
Definition
number AsyncCommand.GetErrorCode(asyncCmd)
Arguments
asyncCmd - async command to query.
Return Values
A result code indicating the error that occurred.
The result returned can be one of the following:
AsyncErr.Unspecified = 1
AsyncErr.System = 2
AsyncErr.Fatal = 3
AsyncErr.ServerError = 4
AsyncErr.SystemUnavailabie = 5
AsyncErr.Aborted = 6
AsyncErr. PermissionDenied = 7
AsyncErr. LimitExceeded = 8
AsyncErr.AuthenticationFail = 10
AsyncErr.NotFound = 11
AsyncErr.Blacklisted = 12
AsyncErr. AlreadyExists = 13
AsyncErr.Timeout = 14
AsyncErr.Busy = 15
AsyncErr.Censored = 16
AsyncErrRanking.ScoreNotFound = 101
AsyncErrFtanking.BoardNotFound = 102
AsyncErrFtanking.InvalidScore = 103
AsyncErrRanking.NotBestScore = 105
AsyncErrTrophy.UnknownTitle = 300
AsyncErrTrophy.InvalidCommld = 301
Description
The result code is only valid if the command failed; the code should not expect any specific result code for a pending or successful command.
Result codes will be fixed, in that the same error will always produce the same result code.
Examples
if (not asyncCmd:Succeeded()) then
print('Async command failed with result: ' .. asyncCmd:GetErrorCode())
end
See Also
� AsyncCommand.Succeeded
AsyncCommand.GetNpErrorCode
Brief
Gets the internal result code in the event of a command error result.
Definition
string AsyncCommand.GetNpErrorCode(asyncCmd)
Arguments
asyncCmd - async command to query.
Return Values
A result code indicating the error that occurred.
Description
The result code is only valid if the command failed; the code should not expect any specific result code for a pending or successful command.
Result codes will be fixed, in that the same error will always produce the same result code. This command can be used to identify the cause of an
error more exactly.
Examples
if (not asyncCmd:Succeeded()) then
print('DEBUG: Async command failed with result: ' .. asyncCmd:GetNpErrorCode())
end
See Also
� AsyncCommand.Succeeded
� AsyncCommand.GetErrorCode
AsyncCommand.GetResultCount
Brief
Indicates the number of results available.
Definition
! number AsyncCommand.GetResultCount( AsyncCommand asyncCmd )
Arguments
asyncCmd - async command to query.
Return Values
The number of results available.
Description
Returns the number of results available from the most recent execution of the command.
Examples
! print(AsyncCommand.GetResultCount( asyncCmd ) .. ' results.')
See Also
AsyncCommand.GetResults
Brief
Access the results of the command.
Definition
value|table|array AsyncCommand.GetResults(AsyncCommand asyncCmd)
Arguments
asyncCmd - async command to query.
Return Values
A command-dependent value or table of values representing the results of the command.
Description
If the command has not successfully completed, nil will be returned. The exact format of the results is command-dependent, see the
documentation for individual commands.
Examples
! if (asyncCmd:IsFinished() and asyncCmd:Succeeded()) then
print('Command results were: asyncCmd:GetResults())
| end
See Also
� AsyncCommand.Succeeded
AsyncCommand.IsFinished
Brief
Indicates if the command has completed, either successfully or with an error.
Definition
boolean AsyncCommand.IsFinished(asyncCmd)
Arguments
asyncCmd - async command to query.
Return Values
true if the command has completed, false if not submitted or still in progress.
Description
Note that if a command has not yet been executed (only created), both IsinProgress and IsFinished will return false. This function will still return
true if the command finishes with an error; to determine whether the command succeeded or failed query AsyncCommand.Succeeded().
Examples
! if (asyncCmd:IsFinished() and asyncCmd:Succeeded()) then
print('Results were: asyncCmd:GetResult())
| end
See Also
AsyncCommand. IsinProgress
� AsyncCommand.Succeeded
� AsyncCommand.GetErrorCode
AsyncCommand. IsInProgress
Brief
Indicates if the command has been submitted but has not yet completed.
Definition
! boolean AsyncCommand.IsInProgress(asyncCmd)
Arguments
asyncCmd - async command to query.
Return Values
Returns true if command has been submitted and is not yet complete, or false otherwise.
Description
Note that if a command has not yet been executed (only created), both IsInProgress and IsFinished will return false.
Examples
! if (asyncCmd:IsInProgress()) then
print('Processing...')
| end
See Also
� AsyncCommand.IsFinished
AsyncCommand.Succeeded
Brief
Indicates if the command succeeded or failed.
Definition
! boolean AsyncCommand.Succeeded(asyncCmd)
Arguments
asyncCmd - async command to query.
Return Values
Returns true if the command is complete and succeeded, false otherwise.
Description
If the command has not been submitted or is still in progress, false will be returned. This should not be confused with the command failing, which
can only be determined once the command is finished.
Examples
if (not asyncCmd:Succeeded()) then
print('Async command failed with result: ', asyncCmd:GetErrorCode())
end
See Also
� AsyncCommand.GetErrorCode
� AsyncCommand.GetResults
AsyncContext
AsyncContext.Create
Brief
Creates a new asynchronous execution context.
Definition
AsyncContext AsyncContext.Create(AsyncContexts type, ...)
Arguments
type - the type of context to create. Can be one of the following:
AsyncContexts.TitleUserStorage
AsyncContexts.Trophy
AsyncContexts.ScoreRanking
AsyncContexts. Inventory
AsyncContexts. ObjectCatalog
AsyncContexts.Stream
AsyncContexts.SaveData
Return Values
The new async execution context, or nil if creation failed.
Description
Most async commands require the creation of an execution context in order to run. The context will typically specify details of the title and/or user
the script wishes to target with the command. Note: It is good practice to nil your context if you will not use it again for the life of the script.
Examples
� this creates a context to access the current user's TUS data for (non-existent) title NPWR99999
local passphrase = Resource.Find('passphrase')
local context = AsyncContext.Create(AsyncContexts.TitleUserStorage, "NPWR99999", passphrase)
See Also
� AsyncCommand.Create
|