     private var socket: Socket?
         
     private var errorHandler: ((Error) -> ())? = nil
-    private var handlers = [String : [String : (Message) -> ()]]()
+    private var handlers = [String: [String: Registration]]()
     private var replyHandlers = [String: (Response) -> ()]()
     private let replyHandlersMutex = Mutex(recursive: true)
     

        self.errorHandler = errorHandler
    }

    public enum Error : Swift.Error {
        case invalidData(data: JSON)
        case serverError(message: String)
        case disconnected(cause: Swift.Error?)
    }
}

        }

        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)) })
        }
    }

