     ///  ```swift
     ///  let client = ActionCableClient(URL: NSURL(string: "ws://localhost:3000/cable")!)
     ///  ```
-    public required init(url: URL) {
+    public required init(url: URL, headers: [String: String]? = nil, origin : String? = nil) {
         /// Setup Initialize Socket
-        socket = WebSocket(url: url)
+        var request = URLRequest(url: url)
+        
+        if let origin = origin {
+            request.setValue(origin, forHTTPHeaderField: "Origin")
+        }
+        
+        for (field, value) in headers ?? [:] {
+            request.setValue(value, forHTTPHeaderField: field)
+        }
+        
+        socket = WebSocket(request: request)
         setupWebSocket()
     }
     

extension ActionCableClient {
    
    fileprivate func setupWebSocket() {
        self.socket.onConnect    = { [weak self] in self!.didConnect() }
        self.socket.onDisconnect = { [weak self] (error: Swift.Error?) in self!.didDisconnect(error) }
        self.socket.onText       = { [weak self] (text: String) in self!.onText(text) }
        self.socket.onData       = { [weak self] (data: Data) in self!.onData(data) }

    //MARK: Properties
    open var isConnected : Bool { return socket.isConnected }
    open var url: Foundation.URL { return socket.currentURL }

  
    /// Initialize an ActionCableClient.
    ///
