summaryrefslogtreecommitdiff
path: root/public/panorama/uiwebapiclient.h
blob: d4afd89bb0716b5e359b46d055d935d9ce6ab0a6 (plain) (blame)
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
//=========== 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