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

Crash when server returns a disconnect response

dmorgereth opened this issue · comments

Our rails server occasionally returns the following response

{"type":"disconnect","reason":"unauthorized","reconnect":false}"

This will cause the code to crash on line 112 of JSONSerializer.swift:

            return Message(channelIdentifier: channelIdentifier!,      // <<-- there is no "identifier" member in the response, so channelIdentfier will be nil
                           actionName: messageActionName,
                           messageType: MessageType.message,
                           data: messageValue,
                           error: messageError)

Recommend that the code be fixed to not force-unwrap channelIdentifier and treat the disconnect the same as a reject