     
     public func setCipher(cipher: String) {
         self.cipher = cipher;
+    }
+    
+    private func currentTimeMillis() -> Int64 {
+        let nowDouble = NSDate().timeIntervalSince1970
+        return Int64(nowDouble * 1000)
     }
     
     public required init(pubKey : String, subKey : String, secretKey : String, cipher : String, connected : Connected? ) {

    
    private func handleMqttDisconnect(session: SwiftMQTT.MQTTSession, token : String, connected : Connected?) {
        if (self.active) {
            print("Connection dropped -> reconnection in 5 sec.")
            DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(5)) {
                session.connect(completion: { [weak self] mqtt_connected, error in
                    self?.handleMqttConnection(succeed: mqtt_connected, error: error, token: token, connected: connected)
                });
            }
        }
    }

        
        self.connectionPoints(callback: { [weak self] token, settings in
            self?.settings = settings;
            self?.tokenExp[token] = self?.currentTimeMillis();
            
            self?.initMqtt(token: token) { status, magistral in
                connected?(status, magistral);
