 
     //Mark: EventListeners
 
-    open func onOpen(_ onOpenCallback: @escaping (Void) -> Void) {
+    open func onOpen(_ onOpenCallback: @escaping ((Void) -> Void)) {
         self.onOpenCallback = onOpenCallback
     }
 
-    open func onError(_ onErrorCallback: @escaping (NSError?) -> Void) {
+    open func onError(_ onErrorCallback: @escaping ((NSError?) -> Void)) {
         self.onErrorCallback = onErrorCallback
 
         if let errorBeforeSet = self.errorBeforeSetErrorCallBack {
             self.onErrorCallback!(errorBeforeSet)
-            self.errorBeforeSetErrorCallBack = nil;
-        }
-    }
-
-    open func onMessage(_ onMessageCallback: @escaping (_ id: String?, _ event: String?, _ data: String?) -> Void) {
+            self.errorBeforeSetErrorCallBack = nil
+        }
+    }
+
+    open func onMessage(_ onMessageCallback: @escaping ((_ id: String?, _ event: String?, _ data: String?) -> Void)) {
         self.onMessageCallback = onMessageCallback
     }
 
-    open func addEventListener(_ event: String, handler: @escaping (_ id: String?, _ event: String?, _ data: String?) -> Void) {
+    open func addEventListener(_ event: String, handler: @escaping ((_ id: String?, _ event: String?, _ data: String?) -> Void)) {
         self.eventListeners[event] = handler
+    }
+
+    open func removeEventListener(_ event: String) -> Void {
+        self.eventListeners.removeValue(forKey: event)
+    }
+
+    open func events() -> Array<String> {
+        return Array(self.eventListeners.keys)
     }
 
     //MARK: URLSessionDataDelegate

            return
        }

        if(error == nil || error!._code != -999) {
            let nanoseconds = Double(self.retryTime) / 1000.0 * Double(NSEC_PER_SEC)
            let delayTime = DispatchTime.now() + Double(Int64(nanoseconds)) / Double(NSEC_PER_SEC);
            DispatchQueue.main.asyncAfter(deadline: delayTime) {
                self.connect()
            }

        self.receivedString = nil
        self.receivedDataBuffer = NSMutableData()


        var port = ""
        if let optionalPort = self.url.port {
            port = String(optionalPort)
        }
        let relativePath = self.url.relativePath
        let host = self.url.host ?? ""

        self.uniqueIdentifier = "\(self.url.scheme).\(host).\(port).\(relativePath)"
        self.lastEventIDKey = "\(EventSource.DefaultsKey).\(self.uniqueIdentifier)"

        super.init()
        self.connect()
    }

