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

first event no callback

chakery opened this issue · comments

after subscribed channel, the first event not callback.

Which event are you looking for?

I think the channel doesn't subscribe for some reason, @danielrhodes. If so, I have the same issue many times

First of all, did you retain the channel somewhere? I kind of want to change the design of the library somewhat to make this not necessary as I used another realtime library and was unhappy with having a separate channel object.

@danielrhodes Actually having a separate Channel object is great. In our app we have Websocket object as a singleton at all times, and create Channel's on demand, whenever user needs them. This flow makes sense also because Starscream library seems to fail to cleanup properly, and crash when we recreate Websocket object =)

I am not, @danielrhodes. I have it like

    var webSocketsRoomChannel: Channel {
        let channelIdPayload = ["channel_id" : viewModel.channel?.identifier]
        let channel = SocketRouter.shared.client.create(WebSocketEventsChannel.channel, identifier: channelIdPayload, autoSubscribe: true, bufferActions: true)
        return channel
    }

I also agree and have the same flow as @DenHeadless

Server-side to send the event changed to asynchronous, it is solved.