public void AddGameState(string json) { if (string.IsNullOrEmpty(json)) { throw new ArgumentException("Can't process an empty gamestate"); } // Try to parse the gamestate frame GameStateFrame frame = new GameStateFrame(); try { frame.FromJson(json); } catch (Exception e) { throw new ArgumentException("Failed parsing a frame from the provided json input", e); } // Let the callbacks handle the frame lock (callbacks) { foreach (var callback in callbacks) { callback(frame); } } }
public void AddGameState(string json) { if(!string.IsNullOrEmpty(json)) { // Create a frame object and parse the json GameStateFrame frame = new GameStateFrame(); frame.FromJson(json); // Let the callbacks handle the frame lock (callbacks) { foreach (var callback in callbacks) { callback(frame); } } } }