zoukankan      html  css  js  c++  java
  • 这些代码都是 吃屁的,

       XMPPElementReceipt *receipt = [XMPPElementReceiptnew];

    //    * - Do an instantaneous check (pass timeout == 0)

    //    * - Wait until the element has been sent (pass timeout < 0)

    //    * - Wait up to a certain amount of time (pass timeout > 0)

        [mStream sendElement:message andGetReceipt:&receipt];

        [receipt wait:-1];

     

    //    * 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

    //            * }

        if ([receipt wait:-1])

        {

            TTLog(@"was sent");

        }

        else{

            TTLog(@"sent faild");

        }

     1,receipt wait = 0,即时检查,不过要 结合timer,不然的话,马上检查一定发送失败的,

    2,receipt wait > 0,等上几分钟检查,如果是 放到主线程,会卡几分钟的,如果改成异步的是没有问题的,不过,即便是异步,设置等待的时间太短,即便发送成功了,也会返回no 的

     BOOL messageState =[receipt wait:0.0000001];

        if (messageState)

        {

            TTLog(@"was sent");

        }

        else{

            TTLog(@"sent faild");

        }

    3,receipt wait < 0,等待发送完检查,同样的放到主线程,会卡的,同上,

  • 相关阅读:
    Qt中widget重新setParent需要注意的问题
    在有状态机下,写自动测试需要注意的问题
    C#获取当前路径的7种方法
    VS快捷键大全
    [WPF]设置背景色
    [WPF]建立自适应窗口大小布局的WinForm窗口
    [WPF]Slider控件常用方法
    [C#.NET]
    VB中的API详解
    VB6.0和VB.Net的函数等对照表
  • 原文地址:https://www.cnblogs.com/guligei/p/3513908.html
Copyright © 2011-2022 走看看