mco_iot_comm_find_conn
此函数返回由 agentId 找到的连接。
请注意,mco_iot_comm_find_conn() 和 mco_iot_comm_next_conn() API 会“锁定/固定”连接句柄以保护句柄不被销毁。当不再需要句柄时,应通过调用 mco_iot_conn_release() 来移除“固定”。
从“固定/取消固定”的角度来看,更安全的枚举活动连接的方法是使用 mco_iot_replicator_enum_agents() API。
iot_connection_h mco_iot_comm_find_conn(
mco_iot_comm_h comm,
mco_iot_agent_id_t agent_id
);有关概述,请参阅主动复制结构页面。
参数
comm
mco_iot_comm_h
通信器对象。
agent_id
const char
要查找的设备 ID。
返回
iot_connection_h
如果未找到该 agent_id 的连接,则返回 NULL。
示例
{
...
mco_iot_connection_h conn = mco_iot_comm_find_conn(comm, agent_id);
if (conn)
{
// Do something with connection conn
mco_iot_conn_release(conn);
}
}文件
- 头文件:
mcoiot.h - 源文件:
mcoiotcomm.c - 库:
libmcoiotcomm.a
