rabbitmq / rabbitmq-objc-client

RabbitMQ client for Objective-C and Swift
https://rabbitmq.com
Other
241 stars 84 forks source link

Add isConnected as delegate method #143

Closed Jasperav closed 5 years ago

Jasperav commented 5 years ago

When a user is connected through recovery, I am notified by the following delegate method:

public func recoveredConnection(_ connection: RMQConnection!) { ... }

However, there is some time between starting a connection and receiving a callback if the connection is successful or not. I only get notified by a delegate method if a connection has failed. How am I supposed to know if a connection is still being made, or is successful? If an extra method isConnected could be added as delegate method, I can determine the current state of the connection:

The delegate method can be added here (I think):

RMQConnection.m, line 301

Is it possible to make an else statement and call the new delegate method isConnected? I am having trouble getting the project compiling because I am missing files (local problems).

Edit: there is a completion handler available when starting the connection, but it gets called even before the handshake. A state property that indicates the state of the connection would be useful.

michaelklishin commented 5 years ago

This is a duplicate of #133. Bunny, the client this one is modelled after, has Bunny::Session#open? and Bunny::Session#connecting?, and their implementation is more or less straightforward.

A PR that adds those methods (with tests please) would be welcome. A specific idea can be discussed in #133 before we move on to writing any code.