         }
       }
     }
-    
+
     func resetBufferTimer() {
       sendBufferTimer?.invalidate()
       sendBufferTimer = NSTimer.scheduledTimerWithTimeInterval(NSTimeInterval(flushEverySec), target: self, selector: Selector("flushSendBuffer"), userInfo: nil, repeats: true)
     }
-    
+
     func onOpen() {
       reconnectTimer?.invalidate()
       heartbeatTimer?.invalidate()
       heartbeatTimer = NSTimer.scheduledTimerWithTimeInterval(NSTimeInterval(heartbeatAfterSec), target: self, selector: Selector("sendHeartbeat"), userInfo: nil, repeats: true)
       rejoinAll()
     }
-    
+
     func onClose(event: String) {
       heartbeatTimer?.invalidate()
       reconnectTimer?.invalidate()
       reconnectTimer = NSTimer.scheduledTimerWithTimeInterval(NSTimeInterval(reconnectAfterSec), target: self, selector: Selector("reconnect"), userInfo: nil, repeats: true)
     }
-    
+
     func onError(error: NSError) {
       print("Error: \(error)")
     }
-    
+
     func isConnected() -> Bool {
       if let connection = self.conn {
         return connection.isConnected
       } else {
         return false
       }
-      
-    }
-    
+
+    }
+
     func rejoinAll() {
       for chan in channels {
         rejoin(chan as Phoenix.Channel)
       }
     }
-    
+
     func rejoin(chan: Phoenix.Channel) {
       chan.reset()
       let joinMessage = chan.message ?? Phoenix.Message(subject: "status", body: "joining")

      }
      bindings = newBindings
    }
    
    func trigger(triggerEvent: String, msg: Phoenix.Message) {
      for binding in bindings {
        if binding.event == triggerEvent {

        resetBufferTimer()
      }
    }

    func doSendBuffer(data: Phoenix.Payload) {
      if let connection = self.conn {
        let json = self.payloadToJson(data)
