scripting:restcallback
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
scripting:restcallback [2022/08/25 14:45] – created jerryhopper | scripting:restcallback [2022/08/25 15:05] (current) – [Common usage] jerryhopper | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== RestCallback ====== | ||
+ | |||
+ | **Class:** RestCallback | ||
+ | |||
+ | **Parent Class:** (?none?) | ||
+ | |||
+ | **Location: | ||
+ | |||
+ | **Description: | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== Common usage ===== | ||
+ | |||
+ | The restAPI allows interaction with external webresources in JSON format. the RestCallback class contains functions in which you process the restAPI request results. | ||
+ | |||
+ | Typical usage : statistics/ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | class TestCallback : RestCallback | ||
+ | { | ||
+ | override void OnSuccess( string data, int dataSize ) | ||
+ | { | ||
+ | Print(" | ||
+ | if( dataSize > 0 ) | ||
+ | Print(data); | ||
+ | }; | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | --- | ||
+ | |||
+ | |||
+ | ===== Functions ===== | ||
+ | |||
+ | ==== OnError(); ==== | ||
+ | |||
+ | OnError( int errorCode ); | ||
+ | |||
+ | Called in case request failed (ERestResult) - Note! May be called multiple times in case of (RetryCount > 1) | ||
+ | |||
+ | Return type: [[scripting: | ||
+ | |||
+ | ==== OnTimeout(); | ||
+ | |||
+ | OnTimeout( | ||
+ | |||
+ | Called in case request timed out or handled improperly (no error, no success, no data) | ||
+ | |||
+ | Return type: [[scripting: | ||
+ | |||
+ | ==== OnSuccess(); | ||
+ | |||
+ | OnSuccess( string data, int dataSize ); | ||
+ | |||
+ | Called when data arrived and/ or response processed successfully | ||
+ | |||
+ | Return type: [[scripting: | ||
+ | |||
+ | |||
+ | |||
+ | ==== OnFileCreated(); | ||
+ | |||
+ | OnFileCreated( string fileName, int dataSize ); | ||
+ | |||
+ | |||
+ | Called when data arrived and/ or file created successfully | ||
+ | |||
+ | |||
+ | Return type: [[scripting: | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== FULL EXAMPLE ===== | ||
+ | |||
+ | < | ||
+ | class TestCallback : RestCallback | ||
+ | { | ||
+ | |||
+ | void OnError( int errorCode ) | ||
+ | { | ||
+ | // override this with your implementation | ||
+ | Print(" | ||
+ | }; | ||
+ | |||
+ | void OnTimeout() | ||
+ | { | ||
+ | // override this with your implementation | ||
+ | Print(" | ||
+ | }; | ||
+ | |||
+ | void OnSuccess( string data, int dataSize ) | ||
+ | { | ||
+ | // override this with your implementation | ||
+ | Print(" | ||
+ | if( dataSize > 0 ) | ||
+ | Print(data); | ||
+ | }; | ||
+ | |||
+ | |||
+ | void OnFileCreated( string fileName, int dataSize ) | ||
+ | { | ||
+ | // override this with your implementation | ||
+ | Print(" | ||
+ | }; | ||
+ | } | ||
+ | </ | ||
- | RestCallback |
scripting/restcallback.1661435154.txt.gz · Last modified: 2022/08/25 14:45 by jerryhopper