danielrhodes / Swift-ActionCableClient

ActionCable is a new WebSocket server being released with Rails 5 which makes it easy to add real-time features to your app. This Swift client makes it dead-simple to connect with that server, abstracting away everything except what you need to get going.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check isConnected in connect() method to avoid duplicate connections

allaire opened this issue · comments

I think it would make sense to make sure we are not already connected in the connect() method, because if you call connect to an active connection, it breaks it.

Finally wrapped it in my manager class, but I think it would make sense to guard the connect method with isConnected. I don't see much value in having multiple connections under the same ActionCableClient instance, or maybe I'm missing something?

A similar idea is present in the ActionCable JS client: https://github.com/rails/rails/blob/master/actioncable/app/assets/javascripts/action_cable/connection.coffee#L24