Tizen(Headed) Native API
6.5
|
The cion server API provides functions for cion server.
Required Header
#include <cion.h>
Overview
The cion server can accept connection request and send or receive data. It provides functions to create cion server and communication APIs.
Functions | |
int | cion_server_create (cion_server_h *server, const char *service_name, const char *display_name, cion_security_h security) |
Creates the Cion server handle. | |
int | cion_server_destroy (cion_server_h server) |
Destroys the Cion server handle. | |
int | cion_server_listen (cion_server_h server, cion_server_connection_request_cb cb, void *user_data) |
Starts listening to connection requests from clients. | |
int | cion_server_stop (cion_server_h server) |
Stops listening to connection requests from clients. | |
int | cion_server_disconnect (cion_server_h server, cion_peer_info_h peer_info) |
Disconnects from a client. | |
int | cion_server_send_payload_async (cion_server_h server, cion_peer_info_h peer_info, cion_payload_h payload, cion_server_payload_async_result_cb cb, void *user_data) |
Sends payload asynchronously. | |
int | cion_server_foreach_connected_peer_info (cion_server_h server, cion_server_connected_peer_info_cb callback, void *user_data) |
Gets connected peers information. | |
int | cion_server_add_connection_result_cb (cion_server_h server, cion_server_connection_result_cb cb, void *user_data) |
Adds callback function for connection result. | |
int | cion_server_remove_connection_result_cb (cion_server_h server, cion_server_connection_result_cb cb) |
Removes callback function for connection result. | |
int | cion_server_add_payload_received_cb (cion_server_h server, cion_server_payload_received_cb cb, void *user_data) |
Adds callback function to receive payload. | |
int | cion_server_remove_payload_received_cb (cion_server_h server, cion_server_payload_received_cb cb) |
Removes callback function to receive payload. | |
int | cion_server_set_data_received_cb (cion_server_h server, cion_server_data_received_cb cb, void *user_data) |
Sets callback function to receive data. | |
int | cion_server_unset_data_received_cb (cion_server_h server) |
Unsets callback function to receive data. | |
int | cion_server_add_disconnected_cb (cion_server_h server, cion_server_disconnected_cb cb, void *user_data) |
Adds callback function for disconnection event. | |
int | cion_server_remove_disconnected_cb (cion_server_h server, cion_server_disconnected_cb cb) |
Removes callback function for disconnection event. | |
int | cion_server_accept (cion_server_h server, const cion_peer_info_h peer_info) |
Accepts the connection request from a peer. | |
int | cion_server_reject (cion_server_h server, const cion_peer_info_h peer_info, const char *reason) |
Rejects the connection request from a peer. | |
int | cion_server_set_display_name (cion_server_h server, const char *display_name) |
Sets the server display name. | |
int | cion_server_set_on_demand_launch_enabled (cion_server_h server, bool enabled) |
Sets on-demand launch state. | |
Typedefs | |
typedef void * | cion_server_h |
The Cion server handle. | |
typedef bool(* | cion_server_connected_peer_info_cb )(const cion_peer_info_h peer_info, void *user_data) |
Called to get the connected peer information. | |
typedef void(* | cion_server_connection_result_cb )(const char *service_name, const cion_peer_info_h peer_info, const cion_connection_result_h result, void *user_data) |
Called when the connection is accepted or rejected. | |
typedef void(* | cion_server_payload_async_result_cb )(const cion_payload_async_result_h result, void *user_data) |
Called after sending payload asynchronously. | |
typedef void(* | cion_server_data_received_cb )(const char *service_name, const cion_peer_info_h peer_info, const unsigned char *data, unsigned int data_size, unsigned char **return_data, unsigned int *return_data_size, void *user_data) |
Called when data is received. | |
typedef void(* | cion_server_payload_received_cb )(const char *service_name, const cion_peer_info_h peer_info, const cion_payload_h payload, cion_payload_transfer_status_e status, void *user_data) |
Called when payload is received. | |
typedef void(* | cion_server_connection_request_cb )(const char *service_name, const cion_peer_info_h peer_info, void *user_data) |
Called when a connection is requested. | |
typedef void(* | cion_server_disconnected_cb )(const char *service_name, const cion_peer_info_h peer_info, void *user_data) |
Called when a peer disconnects. |
Typedef Documentation
typedef bool(* cion_server_connected_peer_info_cb)(const cion_peer_info_h peer_info, void *user_data) |
Called to get the connected peer information.
- Since :
- 6.5
- Parameters:
-
[in] peer_info The Cion peer information handle
The peer_info can be used only in the callback. To use outside, make a copy.[in] user_data The user data
- Returns:
true
to continue with the next iteration of the loop, otherwisefalse
to break out of the loop.
typedef void(* cion_server_connection_request_cb)(const char *service_name, const cion_peer_info_h peer_info, void *user_data) |
Called when a connection is requested.
- Since :
- 6.5
- Parameters:
-
[in] service_name The name of service
The service_name can be used only in the callback. To use outside, make a copy.[in] peer_info The Cion peer information handle
The peer_info can be used only in the callback. To use outside, make a copy.[in] user_data The user data
- See also:
- cion_server_listen()
- cion_peer_info_h
typedef void(* cion_server_connection_result_cb)(const char *service_name, const cion_peer_info_h peer_info, const cion_connection_result_h result, void *user_data) |
Called when the connection is accepted or rejected.
- Since :
- 6.5
- Parameters:
-
[in] service_name The name of service
The service_name can be used only in the callback. To use outside, make a copy.[in] peer_info The Cion peer information handle
The peer_info can be used only in the callback. To use outside, make a copy.[in] result The handle for connection result
The result can be used only in the callback. To use outside, make a copy.[in] user_data The user data
typedef void(* cion_server_data_received_cb)(const char *service_name, const cion_peer_info_h peer_info, const unsigned char *data, unsigned int data_size, unsigned char **return_data, unsigned int *return_data_size, void *user_data) |
Called when data is received.
- Since :
- 6.5
- Remarks:
- The server should return reply by setting return_data and return_data_size.
- Parameters:
-
[in] service_name The name of service
The service_name can be used only in the callback. To use outside, make a copy.[in] peer_info The Cion peer information handle
The peer_info can be used only in the callback. To use outside, make a copy.[in] data The data
The peer_info can be used only in the callback. To use outside, make a copy.[in] data_size The size of data [out] return_data The data to return [out] return_data_size The size of return data [in] user_data The user data
typedef void(* cion_server_disconnected_cb)(const char *service_name, const cion_peer_info_h peer_info, void *user_data) |
Called when a peer disconnects.
- Since :
- 6.5
- Parameters:
-
[in] service_name The name of service
The service_name can be used only in the callback. To use outside, make a copy.[in] peer_info The Cion peer information handle
The peer_info can be used only in the callback. To use outside, make a copy.[in] user_data The user data
typedef void* cion_server_h |
The Cion server handle.
- Since :
- 6.5
typedef void(* cion_server_payload_async_result_cb)(const cion_payload_async_result_h result, void *user_data) |
Called after sending payload asynchronously.
- Since :
- 6.5
- Parameters:
-
[in] result The result of sending payload
The result can be used only in the callback. To use outside, make a copy.[in] user_data The user data
typedef void(* cion_server_payload_received_cb)(const char *service_name, const cion_peer_info_h peer_info, const cion_payload_h payload, cion_payload_transfer_status_e status, void *user_data) |
Called when payload is received.
- Since :
- 6.5
- Parameters:
-
[in] service_name The name of service
The service_name can be used only in the callback. To use outside, make a copy.[in] peer_info The Cion peer information handle
The peer_info can be used only in the callback. To use outside, make a copy.[in] payload The received payload
The payload can be used only in the callback.
The payload should not be released.[in] status The status of transfer [in] user_data The user data
Function Documentation
int cion_server_accept | ( | cion_server_h | server, |
const cion_peer_info_h | peer_info | ||
) |
Accepts the connection request from a peer.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server handle [in] peer_info The Cion peer information handle
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter
- Sample code:
#include <cion.h> { int ret; ret = cion_server_accept(server, peer_info); }
int cion_server_add_connection_result_cb | ( | cion_server_h | server, |
cion_server_connection_result_cb | cb, | ||
void * | user_data | ||
) |
Adds callback function for connection result.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server handle. [in] cb The callback function [in] user_data The user data
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter
- Sample code:
#include <cion.h> { int ret; ret = cion_server_add_connection_result_cb(server, _cion_server_connection_result_cb, NULL); }
int cion_server_add_disconnected_cb | ( | cion_server_h | server, |
cion_server_disconnected_cb | cb, | ||
void * | user_data | ||
) |
Adds callback function for disconnection event.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server handle [in] cb The callback function [in] user_data The user data
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter
- Sample code:
#include <cion.h> { int ret; ret = cion_server_add_disconnected_cb(server, _cion_server_disconnected_cb, NULL); }
int cion_server_add_payload_received_cb | ( | cion_server_h | server, |
cion_server_payload_received_cb | cb, | ||
void * | user_data | ||
) |
Adds callback function to receive payload.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server [in] cb The callback function [in] user_data The user data
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter
- Sample code:
#include <cion.h> { int ret; ret = cion_server_add_payload_received_cb(server, _cion_server_payload_received_cb, NULL); }
int cion_server_create | ( | cion_server_h * | server, |
const char * | service_name, | ||
const char * | display_name, | ||
cion_security_h | security | ||
) |
Creates the Cion server handle.
The Cion server listens client requests.
- Since :
- 6.5
- Remarks:
- server must be released using cion_server_destroy().
- Max length of service_name including the null terminator is 512.
- Parameters:
-
[out] server The Cion server handle [in] service_name The name of service [in] display_name The display name of service [in] security The Cion security handle
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_NOT_SUPPORTED Not supported CION_ERROR_INVALID_PARAMETER Invalid parameter CION_ERROR_OUT_OF_MEMORY Out of memory CION_ERROR_IO_ERROR IO error CION_ERROR_INVALID_OPERATION Invalid operation CION_ERROR_OPERATION_FAILED Operation failed
- Sample code:
#include <cion.h> { int ret; cion_server_h server = NULL; ret = cion_server_create(&server, "myservice", "mydisplayname", NULL); }
int cion_server_destroy | ( | cion_server_h | server | ) |
Destroys the Cion server handle.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server handle.
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter
- See also:
- cion_server_create()
- Sample code:
#include <cion.h> { int ret; ret = cion_server_destroy(server); }
int cion_server_disconnect | ( | cion_server_h | server, |
cion_peer_info_h | peer_info | ||
) |
Disconnects from a client.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server handle [in] peer_info The Cion peer information handle
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter
- Sample code:
#include <cion.h> { int ret; ret = cion_server_disconnect(server, peer_info); }
int cion_server_foreach_connected_peer_info | ( | cion_server_h | server, |
cion_server_connected_peer_info_cb | callback, | ||
void * | user_data | ||
) |
Gets connected peers information.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server handle [in] callback The callback function [in] user_data The user data
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter
- See also:
- cion_server_connected_peer_info_cb()
- Sample code:
#include <cion.h> { int ret; ret = cion_server_foreach_connected_peer_info(server, _cion_server_connected_peer_info_cb, NULL); }
int cion_server_listen | ( | cion_server_h | server, |
cion_server_connection_request_cb | cb, | ||
void * | user_data | ||
) |
Starts listening to connection requests from clients.
- Since :
- 6.5
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/d2d.datasharing
http://tizen.org/privilege/internet
- Parameters:
-
[in] server The Cion server handle [in] cb The callback function [in] user_data The user data
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_PERMISSION_DENIED Permission denied CION_ERROR_INVALID_PARAMETER Invalid parameter CION_ERROR_ALREADY_IN_PROGRESS Already in progress
- See also:
- cion_server_connection_request_cb()
- Sample code:
#include <cion.h> { int ret; ret = cion_server_listen(server, _cion_server_connection_request_cb, NULL); }
int cion_server_reject | ( | cion_server_h | server, |
const cion_peer_info_h | peer_info, | ||
const char * | reason | ||
) |
Rejects the connection request from a peer.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server handle [in] peer_info The Cion peer information handle [in] reason The reason of reject
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter
- Sample code:
#include <cion.h> { int ret; ret = cion_server_reject(server, peer_info, "NOT_ALLOWED"); }
int cion_server_remove_connection_result_cb | ( | cion_server_h | server, |
cion_server_connection_result_cb | cb | ||
) |
Removes callback function for connection result.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server handle. [in] cb The callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter
- Sample code:
#include <cion.h> { int ret; ret = cion_server_remove_connection_result_cb(server, _cion_server_connection_result_cb); }
int cion_server_remove_disconnected_cb | ( | cion_server_h | server, |
cion_server_disconnected_cb | cb | ||
) |
Removes callback function for disconnection event.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server handle [in] cb The callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter
- Sample code:
#include <cion.h> { int ret; ret = cion_server_remove_disconnected_cb(server, _cion_server_disconnected_cb); }
int cion_server_remove_payload_received_cb | ( | cion_server_h | server, |
cion_server_payload_received_cb | cb | ||
) |
Removes callback function to receive payload.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server [in] cb The callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter
- Sample code:
#include <cion.h> { int ret; ret = cion_server_remove_payload_received_cb(server, _cion_server_payload_received_cb); }
int cion_server_send_payload_async | ( | cion_server_h | server, |
cion_peer_info_h | peer_info, | ||
cion_payload_h | payload, | ||
cion_server_payload_async_result_cb | cb, | ||
void * | user_data | ||
) |
Sends payload asynchronously.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server handle [in] peer_info The Cion peer information handle [in] payload The payload to send [in] cb The callback function for result [in] user_data The user data
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter CION_ERROR_INVALID_OPERATION Invalid operation
- Sample code:
#include <cion.h> { int ret; ret = cion_server_send_payload_async(server, peer_info, payload, _cion_server_payload_async_result_cb, NULL); }
int cion_server_set_data_received_cb | ( | cion_server_h | server, |
cion_server_data_received_cb | cb, | ||
void * | user_data | ||
) |
Sets callback function to receive data.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server handle [in] cb The callback function [in] user_data The user data
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter
- Sample code:
#include <cion.h> { int ret; ret = cion_server_set_data_received_cb(server, _cion_server_data_received_cb, NULL); }
int cion_server_set_display_name | ( | cion_server_h | server, |
const char * | display_name | ||
) |
Sets the server display name.
The display name is a customized name for server.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server handle [in] display_name The display name
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter CION_ERROR_OUT_OF_MEMORY Out of memory CION_ERROR_IO_ERROR IO error
- Sample code:
#include <cion.h> { int ret; ret = cion_server_set_display_name(server, "MyDPName"); }
int cion_server_set_on_demand_launch_enabled | ( | cion_server_h | server, |
bool | enabled | ||
) |
Sets on-demand launch state.
If the on-demand launch state is enabled, the server is launched on demand when the request comes.
- Since :
- 6.5
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/d2d.remotelaunch
- Parameters:
-
[in] server The Cion server handle [in] enabled The enable state
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_PERMISSION_DENIED Permission denied CION_ERROR_INVALID_PARAMETER Invalid parameter CION_ERROR_OUT_OF_MEMORY Out of memory CION_ERROR_IO_ERROR IO error
- Sample code:
#include <cion.h> { int ret; ret = cion_server_set_on_demand_launch_enabled(server, true); }
int cion_server_stop | ( | cion_server_h | server | ) |
Stops listening to connection requests from clients.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server handle
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter CION_ERROR_INVALID_OPERATION Invalid operation
- See also:
- cion_server_listen()
- Sample code:
#include <cion.h> { int ret; ret = cion_server_stop(server); }
int cion_server_unset_data_received_cb | ( | cion_server_h | server | ) |
Unsets callback function to receive data.
- Since :
- 6.5
- Parameters:
-
[in] server The Cion server handle
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
CION_ERROR_NONE Successful CION_ERROR_INVALID_PARAMETER Invalid parameter
- Sample code:
#include <cion.h> { int ret; ret = cion_server_unset_data_received_cb(server); }