WrathChaos / StompClientLib

Simple STOMP Client library, Swift 3 and 4, 4.2, 5 compatible
https://www.freakycoder.com
MIT License
153 stars 81 forks source link

Reconnect issue #72

Closed jello323 closed 5 years ago

jello323 commented 5 years ago

Hi, can I ask when my socket is disconnected or problems connecting how do I make it try to connect again? Or reconnecting if the connection is disconnected?

WrathChaos commented 5 years ago

Hello @jello323, I could not totally understand your question. There is a built-in method for reconnecting. Reconnect Method

jello323 commented 5 years ago

hmm let me rephrase, where should i put the reconnect statement if the connection fail or if the connection is disconnected?

Currently I put the reconnect statement in

func serverDidSendError(client: StompClientLib!, withErrorMessage description: String, detailedErrorMessage message: String?) {

client.reconnect(request: url as NSURLRequest, delegate: self as StompClientLibDelegate, time: 4.0)

}

but it dont seem to work

WrathChaos commented 5 years ago

stompClientDidDisconnect

You should add the code into this delegate. Also, please check the example code. There is an example of reconnect method.

WrathChaos commented 5 years ago

I just closed this issue because of the stale.

failynsedik commented 4 years ago

stompClientDidDisconnect

You should add the code into this delegate. Also, please check the example code. There is an example of reconnect method.

Following the reconnect example in the example code worked for me. Thank you! 😃

func stompClientDidConnect(client: StompClientLib!) {
   socketClient.subscribe(destination: "/topic/some-topic-here")

   socketClient.reconnect(
      request: socketRequest, delegate: self,
      connectionHeaders: socketHeader, time: 2.0
   )
}
WrathChaos commented 4 years ago

@failynsedik if you have any other problem or enhancement, I'm glad to improve the library :)