source-engine/public/panorama/uiwebapiclient.h

71 lines
3.1 KiB
C
Raw Permalink Normal View History

2020-04-22 16:56:21 +00:00
//=========== 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