Tizen Native API
5.5
|
IoTCon Request provides API to manage client's request.
#include <iotcon.h>
The IoTCon Request API provides methods for managing request handle. Example :
#include <iotcon.h> static void _request_handler(iotcon_resource_h resource, iotcon_request_h request, void *user_data) { int ret, observe_id; iotcon_request_type_e type; iotcon_observe_type_e observe_type; iotcon_options_h options = NULL; iotcon_query_h query = NULL; iotcon_representation_h repr = NULL; ret = iotcon_request_get_options(request, &options); if (IOTCON_ERROR_NONE == ret && options) { // handle options ... } ret = iotcon_request_get_query(request, &query); if (IOTCON_ERROR_NONE == ret && query) { // handle query ... } ret = iotcon_request_get_request_type(request, &type); if (IOTCON_ERROR_NONE != ret) return; if (IOTCON_REQUEST_GET == type) { // handle get ... } if (IOTCON_REQUEST_PUT == type) { // handle put ret = iotcon_request_get_representation(request, &repr); if (IOTCON_ERROR_NONE != ret) return; ... } if (IOTCON_REQUEST_POST == type) { // handle post ret = iotcon_request_get_representation(request, &repr); if (IOTCON_ERROR_NONE != ret) return; ... } if (IOTCON_REQUEST_DELETE == type) { // handle delete ret = iotcon_request_get_representation(request, &repr); if (IOTCON_ERROR_NONE != ret) return; ... } ret = iotcon_request_get_observe_type(request, &observe_type); if (IOTCON_ERROR_NONE != ret) return; if (IOTCON_OBSERVE_REGISTER == observe_type) { ret = iotcon_request_get_observe_id(request, &observe_id); if (IOTCON_ERROR_NONE != ret) return; // handle register observe ... } else if (IOTCON_OBSERVE_DEREGISTER == observe_type) { ret = iotcon_request_get_observe_id(request, &observe_id); if (IOTCON_ERROR_NONE != ret) return; // handle deregister observe ... } ... }
This API is related with the following features:
Functions | |
int | iotcon_request_get_host_address (iotcon_request_h request, char **host_address) |
Gets host address of the request. | |
int | iotcon_request_get_connectivity_type (iotcon_request_h request, iotcon_connectivity_type_e *connectivity_type) |
Gets connectivity type of the request. | |
int | iotcon_request_get_representation (iotcon_request_h request, iotcon_representation_h *repr) |
Gets a representation of the request. | |
int | iotcon_request_get_request_type (iotcon_request_h request, iotcon_request_type_e *type) |
Gets type of the request. | |
int | iotcon_request_get_options (iotcon_request_h request, iotcon_options_h *options) |
Gets options of the request. | |
int | iotcon_request_get_query (iotcon_request_h request, iotcon_query_h *query) |
Gets query of the request. | |
int | iotcon_request_get_observe_type (iotcon_request_h request, iotcon_observe_type_e *observe_type) |
Gets observation action of the request. | |
int | iotcon_request_get_observe_id (iotcon_request_h request, int *observe_id) |
Gets observation ID of the request. |
int iotcon_request_get_connectivity_type | ( | iotcon_request_h | request, |
iotcon_connectivity_type_e * | connectivity_type | ||
) |
Gets connectivity type of the request.
[in] | request | The handle of the request |
[out] | connectivity_type | The connectivity type of the request |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_request_get_host_address | ( | iotcon_request_h | request, |
char ** | host_address | ||
) |
Gets host address of the request.
[in] | request | The handle of the request |
[out] | host_address | The host address of the request |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_request_get_observe_id | ( | iotcon_request_h | request, |
int * | observe_id | ||
) |
Gets observation ID of the request.
[in] | request | The handle of the request |
[out] | observe_id | The ID of the observer |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_request_get_observe_type | ( | iotcon_request_h | request, |
iotcon_observe_type_e * | observe_type | ||
) |
Gets observation action of the request.
The observe_type could be one of iotcon_observe_type_e.
[in] | request | The handle of the request |
[out] | observe_type | The observation type of the request |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_request_get_options | ( | iotcon_request_h | request, |
iotcon_options_h * | options | ||
) |
Gets options of the request.
[in] | request | The handle of the request |
[out] | options | The options of the request |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_request_get_query | ( | iotcon_request_h | request, |
iotcon_query_h * | query | ||
) |
Gets query of the request.
[in] | request | The handle of the request |
[out] | query | The query of the request |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_request_get_representation | ( | iotcon_request_h | request, |
iotcon_representation_h * | repr | ||
) |
Gets a representation of the request.
[in] | request | The handle of the request |
[out] | repr | The representation of the request |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_request_get_request_type | ( | iotcon_request_h | request, |
iotcon_request_type_e * | type | ||
) |
Gets type of the request.
type could be one of the iotcon_request_type_e.
[in] | request | The handle of the request |
[out] | type | The types of the request |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |