【发布时间】:2016-11-11 22:23:46
【问题描述】:
如何在 XMPP 中设置超时?据我搜索,我发现有两个超时。
- 应用程序尝试与服务器建立连接的超时。此超时是可配置的:
[_xmppStream connectWithTimeout:kTimeOutForChat error:&error]
- 与
Spark连接后XMPPStream检查邀请批准/拒绝的超时在库文件中。
我正在寻找允许我在不修改库的情况下配置第二次超时的解决方案。
FileName : XMPPStream.m
#define TIMEOUT_XMPP_READ_STREAM -1
我想要这个-1 到40。我不想编辑库文件。有什么方法可以在不修改库的情况下进行设置?
编辑:代码接近超时宏
/**
* Seeing a return statements within an inner block
* can sometimes be mistaken for a return point of the enclosing method.
* This makes inline blocks a bit easier to read.
**/
#define return_from_block return
// Define the timeouts (in seconds) for retreiving various parts of the XML stream
#define TIMEOUT_XMPP_WRITE -1
#define TIMEOUT_XMPP_READ_START 10
#define TIMEOUT_XMPP_READ_STREAM 40
// Define the tags we'll use to differentiate what it is we're currently reading or writing
#define TAG_XMPP_READ_START 100
#define TAG_XMPP_READ_STREAM 101
#define TAG_XMPP_WRITE_START 200
#define TAG_XMPP_WRITE_STOP 201
#define TAG_XMPP_WRITE_STREAM 202
#define TAG_XMPP_WRITE_RECEIPT 203
// Define the timeouts (in seconds) for SRV
【问题讨论】:
-
显示更多关于定义的代码,它之前是否有 if 语句?库是预先构建的还是您正在构建的?
-
@Wain 这个库是预构建的。我正在通过 Cocoa Pod 安装它。这是 Libray 的链接,我已经更新了我的问题,显示更多代码。 github.com/robbiehanson/XMPPFramework
-
看起来不像是预构建的,但使用预处理器也不容易更改。我建议只是分叉项目并稍微编辑它......
-
是的,我也想这样做。但认为可能存在其他解决方案,或者我无法获得执行此操作的方法名称。无论如何感谢您的解决方案:) @Wain
标签: ios objective-c xmpp xmppframework