private void HandleDisconnection(Disconnect disconnect, Address sender) { var sessionId = this.peers.GetValueOrDefault(disconnect.ClientId); string message; if (sessionId is null) { // Peer not previously connected to a session sessionId = SessionId.None(); message = $"{sender.Value} had no session to disconnect from {this.serviceName.Value}"; this.Logger.LogWarning(LogId.Network, message); } else { // Peer connected to a session this.peers.Remove(disconnect.ClientId); // Pop from dictionary message = $"{sender.Value} disconnected from {this.serviceName.Value} session {sessionId.Value}"; this.Logger.LogInformation(LogId.Network, message); } var response = new Disconnected( message, this.serverId, sessionId, disconnect.Id, this.NewGuid(), this.TimeNow()); this.SendMessage(response, sender); }