diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/panorama/uiwebapiclient.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'public/panorama/uiwebapiclient.h')
| -rw-r--r-- | public/panorama/uiwebapiclient.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/public/panorama/uiwebapiclient.h b/public/panorama/uiwebapiclient.h new file mode 100644 index 0000000..d4afd89 --- /dev/null +++ b/public/panorama/uiwebapiclient.h @@ -0,0 +1,70 @@ +//=========== Copyright Valve Corporation, All rights reserved. ===============// +// +// Purpose: Helper classes/functions for performing web api requests from ui code +// +//=============================================================================// + +#ifndef UIWEBAPICLIENT_H +#define UIWEBAPICLIENT_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "uievent.h" + + +namespace panorama +{ + +//----------------------------------------------------------------------------- +// Purpose: Helper for performing async webapi requests +//----------------------------------------------------------------------------- +inline uint64 MakeAsyncJSONWebAPIRequest( EHTTPMethod eMethod, const char *pchWebAPIURL, CJSONWebAPIParams *pParams, HTTPCookieContainerHandle hCookieContianer, IUIPanel *pCallbackTargetPanel, void *pContext ) +{ + return UIEngine()->InitiateAsyncJSONWebAPIRequest( eMethod, pchWebAPIURL, pCallbackTargetPanel, pContext, pParams, hCookieContianer ); +} + +//----------------------------------------------------------------------------- +// Purpose: Helper for performing async webapi requests +//----------------------------------------------------------------------------- +inline uint64 MakeAsyncJSONWebAPIRequest( EHTTPMethod eMethod, const char *pchWebAPIURL, CJSONWebAPIParams *pParams, HTTPCookieContainerHandle hCookieContianer, JSONWebAPIDelegate_t callback, void *pContext ) +{ + return UIEngine()->InitiateAsyncJSONWebAPIRequest( eMethod, pchWebAPIURL, callback, pContext, pParams, hCookieContianer ); +} + + +//----------------------------------------------------------------------------- +// Purpose: Helper for performing async webapi requests +//----------------------------------------------------------------------------- +inline uint32 MakeAsyncJSONWebAPIRequest( const char *pchWebAPIURL, IUIPanel *pCallbackTargetPanel, void *pContext ) +{ + return UIEngine()->InitiateAsyncJSONWebAPIRequest( k_EHTTPMethodGET, pchWebAPIURL, pCallbackTargetPanel, pContext ); +} + + +//----------------------------------------------------------------------------- +// Purpose: Helper for performing async webapi requests. When using this version, objects pointed to +// by the provided delegate must live for the duration of the web request. Before destroying those objects, +// you must get a completion callback or CancelAsyncJSONWebAPIRequest. +// +// Use panel & event versions above if you do not want to manage object & request lifetimes. +//----------------------------------------------------------------------------- +inline uint32 MakeAsyncJSONWebAPIRequest( const char *pchWebAPIURL, JSONWebAPIDelegate_t callback, void *pContext ) +{ + return UIEngine()->InitiateAsyncJSONWebAPIRequest( k_EHTTPMethodGET, pchWebAPIURL, callback, pContext ); +} + + +//----------------------------------------------------------------------------- +// Purpose: Cancels a job request made by MakeAsyncJSONWebAPIRequest +//----------------------------------------------------------------------------- +inline void CancelAsyncJSONWebAPIRequest( uint32 requestID ) +{ + UIEngine()->CancelAsyncJSONWebAPIRequest( requestID ); +} + + +} // namespace panorama + +#endif // UIWEBAPICLIENT_H |