             let jsonString = String(data: jsonData, encoding: NSUTF8StringEncoding)
             webSocket?.send(jsonString)
 
+            completion?(finish: true)
+
         } catch _ {
             delegate?.fayeClient(self, didFailDeserializeMessage: message)
-        }
-    }
-}
-
+
+            completion?(finish: false)
+        }
+    }
+}
+


        writeMessage(message)
    }
}

// MARK: - SRWebSocket

extension FayeClient {

    func writeMessage(message: [String: AnyObject]) {

        do {
            let jsonData = try NSJSONSerialization.dataWithJSONObject(message, options: NSJSONWritingOptions(rawValue: 0))

    public private(set) var pendingSubscriptionSet: Set<String> = []
    public private(set) var openSubscriptionSet: Set<String> = []

    private var pendingChannelSubscriptionSet: Set<String> = []
    private var subscribedChannels: [String: AnyObject] = [:]
    private var privateChannels: [String: AnyObject] = [:]
    private var channelExtensions: [String: AnyObject] = [:]
