Delete data that have been transmitted and acknowledged by the peer.
MCO_RET mco_iot_replicator_clear(mco_iot_replicator_h repl,
mco_iot_agent_id_t agent_id);
| repl | The replicator object | ||||||||
| agent_id |
The
|
The function deletes data that has been transmitted and acknowledged by the peer; where agent_id is the id of a specific agent or MCO_IOT_ALL_AGENTS.
| MCO_S_OK | Data successfully cleared |
| MCO_E_IOT_INVALID_HANDLE | Invalid replicator handle repl |
| MCO_E_IOT_NOT_INITIALIZED | The IoT runtime was not initialized or the database does not declare IoT in the schema |
| MCO_E_IOT_WRONG_AGENT_ID | The agent_id is not valid
|
| MCO_E_ILLEGAL_PARAM | Incompatible parameter values (e.g. agent_id=MCO_IOT_SERVER_AGENT_ID cannot be used on the server)
|
| MCO_E_SESLIMIT | Or other connect() errors if the function can't create a database connection |
mco_trans_start() errors |
Error starting a transaction |
errors |
Error committing a transaction |
| other errors | Other errors can happen when accessing database to delete unnecessary data |
// onAck callback
int iot_on_ack(mco_iot_connection_h iotc, const iot_ack_t *ack, void *context)
{
// Remove unnecessary data on receiving positive ACK
if (ack->error_code == MCO_S_OK)
{
mco_iot_replicator_h repl = (mco_iot_replicator_h) context;
mco_iot_agent_id_t agent_id = mco_iot_conn_get_agent_id(iotc);
mco_iot_replicator_clear(repl, agent_id);
}
return IOT_CALLBACK_OK;
}