C客户端连接状态检查

C客户端连接状态检查

本文介绍了RabbitMQ Obj-C客户端连接状态检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用。有没有办法检查连接是否成功打开?我看到有RMQConnectionDelegate,但只有错误出现时才调用的方法。我正在寻找类似的东西

I'm using rabbitmq/rabbitmq-objc-client. Is there a way how to check if connection was opened successfully? I see there is RMQConnectionDelegate but there are only methods that are called when an error appears. I'm looking for something like

RMQConnection *conn = [[RMQConnection alloc] /*...*/];
if ([conn isOpen]) {
    /* ... */
}


推荐答案

您可以执行以下操作:

[conn start:^{ // code to execute when connection established }];

但是请注意,客户端是异步的,并且所有通道操作都放在连接后的队列中以便执行

But note that the client is async and all channel operations are placed onto a queue for execution after the connection is established.

我为迈克尔打开的问题添加了注释:

I've added a note to the issue Michael opened: https://github.com/rabbitmq/rabbitmq-objc-client/issues/101

这篇关于RabbitMQ Obj-C客户端连接状态检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-20 22:45