Unless, of course, something horrible happens such as a network failure,

本文介绍了一种类似于sendElement的方法,该方法允许接收回执以验证元素是否已发送。通过使用此方法,可以检查元素是否成功发送,并理解回执返回YES的实际含义。即使在关闭XMPP流之后,操作系统也会尝试发送数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/**

 * Just like the sendElement: method above,

 * but allows you to receive a receipt that can later be used to verify the element has been sent.

 * 

 * If you later want to check to see if the element has been sent:

 * 

 * if ([receipt wait:0]) {

 *   // Element has been sent

 * }

 * 

 * If you later want to wait until the element has been sent:

 * 

 * if ([receipt wait:-1]) {

 *   // Element was sent

 * } else {

 *   // Element failed to send due to disconnection

 * }

 * 

 * It is important to understand what it means when [receipt wait:timeout] returns YES.

 * It does NOT mean the server has received the element.

 * It only means the data has been queued for sending in the underlying OS socket buffer.

 * 

 * So at this point the OS will do everything in its capacity to send the data to the server,

 * which generally means the server will eventually receive the data.

 * Unless, of course, something horrible happens such as a network failure,

 * or a system crash, or the server crashes, etc.

 * 

 * Even if you close the xmpp stream after this point, the OS will still do everything it can to send the data.

**/

- (void)sendElement:(NSXMLElement *)element andGetReceipt:(XMPPElementReceipt **)receiptPtr;

转载于:https://www.cnblogs.com/guligei/p/3510414.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值