Tizen Native API  7.0

The cion group API provides functions for cion group.

Required Header

#include <cion.h>

Overview

The cion group is used to subscribe and publish data. It provides functions to create cion group and communication APIs.

Functions

int cion_group_create (cion_group_h *group, const char *topic_name, cion_security_h security)
 Creates a Cion group handle.
int cion_group_destroy (cion_group_h group)
 Destroys the group handle.
int cion_group_subscribe (cion_group_h group)
 Subscribes to a topic that the group handle has.
int cion_group_unsubscribe (cion_group_h group)
 Unsubscribes from topic that the group handle has.
int cion_group_publish (cion_group_h group, cion_payload_h data)
 Publishes data to the group.
int cion_group_add_payload_received_cb (cion_group_h group, cion_group_payload_received_cb cb, void *user_data)
 Adds callback function to receive payload.
int cion_group_remove_payload_received_cb (cion_group_h group, cion_group_payload_received_cb cb)
 Removes callback function to receive payload.
int cion_group_add_joined_cb (cion_group_h group, cion_group_joined_cb cb, void *user_data)
 Adds callback function for join event.
int cion_group_remove_joined_cb (cion_group_h group, cion_group_joined_cb cb)
 Removes callback function for join event.
int cion_group_add_left_cb (cion_group_h group, cion_group_left_cb cb, void *user_data)
 Adds callback function to get peer leaving information.
int cion_group_remove_left_cb (cion_group_h group, cion_group_left_cb cb)
 Removes callback function to get peer leaving information.

Typedefs

typedef void * cion_group_h
 The Cion group handle.
typedef void(* cion_group_payload_received_cb )(const char *topic_name, const cion_peer_info_h peer_info, cion_payload_h payload, void *user_data)
 Called when the payload is received.
typedef void(* cion_group_joined_cb )(const char *topic_name, const cion_peer_info_h peer_info, void *user_data)
 Called when a peer joins a topic.
typedef void(* cion_group_left_cb )(const char *topic_name, const cion_peer_info_h peer_info, void *user_data)
 Called when a peer leaves a topic.

Typedef Documentation

typedef void* cion_group_h

The Cion group handle.

Since :
6.5
typedef void(* cion_group_joined_cb)(const char *topic_name, const cion_peer_info_h peer_info, void *user_data)

Called when a peer joins a topic.

Since :
6.5
Parameters:
[in]topic_nameThe name of topic
The topic_name can be used only in the callback. To use outside, make a copy.
[in]peer_infoThe Cion peer information handle
The peer_info can be used only in the callback. To use outside, make a copy.
[in]user_dataThe user data
See also:
cion_group_add_joined_cb()
cion_peer_info_h
typedef void(* cion_group_left_cb)(const char *topic_name, const cion_peer_info_h peer_info, void *user_data)

Called when a peer leaves a topic.

Since :
6.5
Parameters:
[in]topic_nameThe name of topic
The topic_name can be used only in the callback. To use outside, make a copy.
[in]peer_infoThe Cion peer information handle
The peer_info can be used only in the callback. To use outside, make a copy.
[in]user_dataThe user data
See also:
cion_group_add_left_cb()
cion_peer_info_h
typedef void(* cion_group_payload_received_cb)(const char *topic_name, const cion_peer_info_h peer_info, cion_payload_h payload, void *user_data)

Called when the payload is received.

Since :
6.5
Parameters:
[in]topic_nameThe name of topic
The topic_name can be used only in the callback. To use outside, make a copy.
[in]peer_infoThe Cion peer information handle
The peer_info can be used only in the callback. To use outside, make a copy.
[in]payloadThe received payload
The payload can be used only in the callback.
The payload should not be released.
[in]user_dataThe user data
See also:
cion_group_add_payload_received_cb()
cion_peer_info_h
cion_payload_h

Function Documentation

int cion_group_add_joined_cb ( cion_group_h  group,
cion_group_joined_cb  cb,
void *  user_data 
)

Adds callback function for join event.

Since :
6.5
Parameters:
[in]groupThe Cion group handle
[in]cbThe callback function
[in]user_dataThe user data
Returns:
0 on success, otherwise a negative error value
Return values:
CION_ERROR_NONESuccessful
CION_ERROR_INVALID_PARAMETERInvalid parameter
See also:
cion_group_joined_cb()
cion_group_remove_joined_cb()
Sample code:
#include <cion.h>

{
    int ret;

    ret = cion_group_add_joined_cb(group, _cion_group_joined_cb, NULL);
}
int cion_group_add_left_cb ( cion_group_h  group,
cion_group_left_cb  cb,
void *  user_data 
)

Adds callback function to get peer leaving information.

Since :
6.5
Parameters:
[in]groupThe Cion group handle
[in]cbThe callback function
[in]user_dataThe user_data
Returns:
0 on success, otherwise a negative error value
Return values:
CION_ERROR_NONESuccessful
CION_ERROR_INVALID_PARAMETERInvalid parameter
See also:
cion_group_left_cb()
cion_group_remove_left_cb()
Sample code:
#include <cion.h>

{
    int ret;

    ret = cion_group_add_left_cb(group, _cion_group_left_cb, NULL);
}

Adds callback function to receive payload.

Since :
6.5
Parameters:
[in]groupThe Cion group handle
[in]cbThe callback function
[in]user_dataThe user data
Returns:
0 on success, otherwise a negative error value
Return values:
CION_ERROR_NONESuccessful
CION_ERROR_INVALID_PARAMETERInvalid parameter
See also:
cion_server_payload_received_cb()
cion_group_remove_payload_received_cb()
Sample code:
#include <cion.h>

{
    int ret;

    ret = cion_group_add_payload_received_cb(group,
            _cion_group_payload_received_cb, NULL);
}
int cion_group_create ( cion_group_h group,
const char *  topic_name,
cion_security_h  security 
)

Creates a Cion group handle.

The Cion group is the group to share data.
The users can subscribe the group that named topic and publish the data to share.

Since :
6.5
Remarks:
group must be released using cion_group_destroy().
Max length of topic_name including the null terminator is 512.
Parameters:
[out]groupThe Cion group handle
[in]topic_nameThe name of topic
[in]securityThe Cion security handle
Returns:
0 on success, otherwise a negative error value
Return values:
CION_ERROR_NONESuccessful
CION_ERROR_NOT_SUPPORTEDNot supported
CION_ERROR_INVALID_PARAMETERInvalid parameter
CION_ERROR_OUT_OF_MEMORYOut of memory
See also:
cion_group_destroy()
cion_security_create()
Sample code:
#include <cion.h>

{
    int ret;
    cion_group_h group = NULL;

    ret = cion_group_create(&group, "mytopic", NULL);
}

Destroys the group handle.

Since :
6.5
Parameters:
[in]groupThe Cion group handle
Returns:
0 on success, otherwise a negative error value
Return values:
CION_ERROR_NONESuccessful
CION_ERROR_INVALID_PARAMETERInvalid parameter
See also:
cion_group_create()
Sample code:
#include <cion.h>

{
    int ret;

    ret = cion_group_destroy(group);
}
int cion_group_publish ( cion_group_h  group,
cion_payload_h  data 
)

Publishes data to the group.

Since :
6.5
Parameters:
[in]groupThe Cion group handle
[in]dataThe data
Returns:
0 on success, otherwise a negative error value
Return values:
CION_ERROR_NONESuccessful
CION_ERROR_INVALID_PARAMETERInvalid parameter
CION_ERROR_INVALID_OPERATIONInvalid operation
Sample code:
#include <cion.h>

{
    int ret;

    ret = cion_group_publish(group, payload);
}

Removes callback function for join event.

Since :
6.5
Parameters:
[in]groupThe Cion group handle
[in]cbThe callback function
Returns:
0 on success, otherwise a negative error value
Return values:
CION_ERROR_NONESuccessful
CION_ERROR_INVALID_PARAMETERInvalid parameter
See also:
cion_group_joined_cb()
cion_group_add_joined_cb()
Sample code:
#include <cion.h>

{
    int ret;

    ret = cion_group_remove_joined_cb(group, _cion_group_joined_cb);
}

Removes callback function to get peer leaving information.

Since :
6.5
Parameters:
[in]groupThe Cion group handle
[in]cbThe callback function
Returns:
0 on success, otherwise a negative error value
Return values:
CION_ERROR_NONESuccessful
CION_ERROR_INVALID_PARAMETERInvalid parameter
See also:
cion_group_left_cb()
cion_group_add_left_cb()
Sample code:
#include <cion.h>

{
    int ret;

    ret = cion_group_remove_left_cb(group, _cion_group_left_cb);
}

Removes callback function to receive payload.

Since :
6.5
Parameters:
[in]groupThe Cion group handle
[in]cbThe callback function
Returns:
0 on success, otherwise a negative error value
Return values:
CION_ERROR_NONESuccessful
CION_ERROR_INVALID_PARAMETERInvalid parameter
See also:
cion_server_payload_received_cb()
cion_group_add_payload_received_cb()
Sample code:
#include <cion.h>

{
    int ret;

    ret = cion_group_remove_payload_received_cb(group,
            _cion_group_payload_received_cb);
}

Subscribes to a topic that the group handle has.

Since :
6.5
Privilege Level:
public
Privilege:
http://tizen.org/privilege/d2d.datasharing
http://tizen.org/privilege/internet
Parameters:
[in]groupThe Cion group handle
Returns:
0 on success, otherwise a negative error value
Return values:
CION_ERROR_NONESuccessful
CION_ERROR_PERMISSION_DENIEDPermission denied
CION_ERROR_INVALID_PARAMETERInvalid parameter
Sample code:
#include <cion.h>

{
    int ret;

    ret = cion_group_subscribe(group);
}

Unsubscribes from topic that the group handle has.

Since :
6.5
Parameters:
[in]groupThe Cion group handle
Returns:
0 on success, otherwise a negative error value
Return values:
CION_ERROR_NONESuccessful
CION_ERROR_INVALID_PARAMETERInvalid parameter
Sample code:
#include <cion.h>

{
    int ret;

    ret = cion_group_unsubscribe(group);
}