public void Process(LocalConnection connection, XElement message) { StateMachine stateMachine; lock (_stateMachines) { if (!_stateMachines.ContainsKey(connection)) { var lobbyConnection = new LobbyConnection(connection, _matchServer, _logOnService); stateMachine = new StateMachine(new ConnectionEstablishedState(lobbyConnection)); stateMachine.Finished += OnConnectionEnded; _stateMachines.Add(connection, stateMachine); } else { stateMachine = _stateMachines[connection]; } } stateMachine.Process(new Message(InvariantConvert.ToString(connection.GetHashCode()), message)); }