public WebSocketPublisher(IWebSocketConnection webSocketConnection) { WebSocketConnection = webSocketConnection; WebSocketConnection.OnMessage = (message) => { var configurationEvent = JsonConvert.DeserializeObject <ConfigurationEvent>(message); DomainEvents.Raise(configurationEvent); }; WebSocketConnection.OnClose = () => DomainEvents.Deregister(this); DomainEvents.Register(this); }