         self.errorHandler = errorHandler
     }
 
+    // TODO: docs
     public enum Error : Swift.Error {
         case invalidData(data: JSON)
         case serverError(message: String)
         case disconnected(cause: Swift.Error?)
     }
+
+    struct Registration {
+        let address: String
+        let id: String
+        let handler: (Message) -> ()
+        let headers: [String: String]
+    }
 }

    public func register(address: String,
                         id: String? = nil,
                         headers: [String: String]? = nil,
                         handler: @escaping ((Message) -> ())) throws -> String {
        let _id = id ?? uuid()
        if let _ = self.handlers[address] {
            self.handlers[address]![_id] = handler
        } else {
            self.handlers[address] = [_id : handler]
        }

        try send(JSON(["type": "register", "address": address, "headers": headers ?? [String: String]()])) 

        return _id
    }

        }

        let msg = Message(basis: json, eventBus: self)
        if let handlers = self.handlers[address] {
            for registration in handlers.values {
                workQueue.async(execute: { registration.handler(msg) })
            }
        } else if let handler = self.replyHandlers[address] {
            workQueue.async(execute: { handler(Response(message: msg)) })
        }
    }

