         }
     }
 
-    private class func onSubscribeAdapter(callback: ((Int, Array<Int32>) -> Void)!) -> ((Int, Int, UnsafePointer<Int32>) -> Void)! {
+    private class func onSubscribeAdapter(callback: ((Int, Array<Int32>) -> ())!) -> ((Int, Int, UnsafePointer<Int32>) -> ())! {
         return callback == nil ? nil : { (messageId: Int, qosCount: Int, grantedQos: UnsafePointer<Int32>) in
             var grantedQosList = [Int32](count: qosCount, repeatedValue: Qos.At_Least_Once)
             Array(0..<qosCount).reduce(grantedQos) { (qosPointer, index) in

        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
            mosquitto_connect(mosquittoContext.mosquittoHandler, host.cCharArray, port, keepAlive)
            mosquitto_loop_start(mosquittoContext.mosquittoHandler)
            mqttClient.operationQueue.suspended = false
        }
        
        return mqttClient
    }

    private class func onConnectAdapter(callback: ((ReturnCode) -> Void)!) -> ((returnCode: Int) -> Void)! {
        return callback == nil ? nil : { (rawReturnCode: Int) in
            let returnCode = rawReturnCode < ReturnCode.Unknown.rawValue ? ReturnCode(rawValue: rawReturnCode) : ReturnCode.Unknown
            callback(returnCode!)
        }
    }

    private class func onDisconnectAdapter(callback: ((ReasonCode) -> Void)!) -> ((reasonCode: Int) -> Void)! {
        return callback == nil ? nil : { (rawReasonCode: Int) in
            let reasonCode = rawReasonCode < ReasonCode.Unexpected.rawValue ? ReasonCode(rawValue: rawReasonCode) : ReasonCode.Unexpected
            callback(reasonCode!)
        }
    }

    private class func onMessageAdapter(callback: ((MQTTMessage) -> Void)!) -> ((UnsafePointer<mosquitto_message>) -> Void)! {
        return callback == nil ? nil : { (rawMessage: UnsafePointer<mosquitto_message>) in
            let message = rawMessage.memory
            let topic = String.fromCString(message.topic)!

public final class __MosquittoContext {
    public var mosquittoHandler: COpaquePointer = COpaquePointer.null()
    public var isConnected: Bool = false
    public var onConnectCallback: ((returnCode: Int) -> ())!
    public var onDisconnectCallback: ((reasonCode: Int) -> ())!
    public var onPublishCallback: ((messageId: Int) -> ())!
    public var onMessageCallback: ((message: UnsafePointer<mosquitto_message>) -> ())!
    public var onSubscribeCallback: ((messageId: Int, qosCount: Int, grantedQos: UnsafePointer<Int32>) -> ())!
    public var onUnsubscribeCallback: ((messageId: Int) -> ())!
    public var keyfile_passwd: String = ""
    internal init(){}
}
