User Tools

Site Tools


scripting:restcallback

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
scripting:restcallback [2022/08/25 15:01] – [Common usage] jerryhopperscripting:restcallback [2022/08/25 15:05] (current) – [Common usage] jerryhopper
Line 14: Line 14:
 ===== Common usage ===== ===== Common usage =====
  
-The restAPI allows interaction with external webresources in JSON format. The callbackContext contains the results or errors from the restAPI request+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/leaderboards/persistent world.  Typical usage : statistics/leaderboards/persistent world. 
Line 31: Line 31:
   }   }
  
- 
-**FULL EXAMPLE** 
- 
-<code> 
-class TestCallback : RestCallback 
-{ 
- 
- void OnError( int errorCode ) 
- { 
- // override this with your implementation 
- Print(" !!! OnError() "); 
- }; 
- 
- void OnTimeout() 
- { 
- // override this with your implementation 
- Print(" !!! OnTimeout() "); 
- }; 
- 
- void OnSuccess( string data, int dataSize ) 
- { 
- // override this with your implementation 
- Print(" !!! OnSuccess() size=" + dataSize ); 
- if( dataSize > 0 ) 
- Print(data); // !!! NOTE: Print() will not output string longer than 1024b, check your dataSize !!! 
- }; 
- 
- 
- void OnFileCreated( string fileName, int dataSize ) 
- { 
- // override this with your implementation 
- Print(" !!! OnFileCreated() file=" + fileName + " size=" + dataSize ); 
- }; 
-} 
-</code> 
  
  
Line 111: Line 76:
  
  
 +
 +===== FULL EXAMPLE =====
 +
 +<code>
 +class TestCallback : RestCallback
 +{
 +
 + void OnError( int errorCode )
 + {
 + // override this with your implementation
 + Print(" !!! OnError() ");
 + };
 +
 + void OnTimeout()
 + {
 + // override this with your implementation
 + Print(" !!! OnTimeout() ");
 + };
 +
 + void OnSuccess( string data, int dataSize )
 + {
 + // override this with your implementation
 + Print(" !!! OnSuccess() size=" + dataSize );
 + if( dataSize > 0 )
 + Print(data); // !!! NOTE: Print() will not output string longer than 1024b, check your dataSize !!!
 + };
 +
 +
 + void OnFileCreated( string fileName, int dataSize )
 + {
 + // override this with your implementation
 + Print(" !!! OnFileCreated() file=" + fileName + " size=" + dataSize );
 + };
 +}
 +</code>
  
  
scripting/restcallback.1661436112.txt.gz · Last modified: 2022/08/25 15:01 by jerryhopper

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki