Inheritance: GameStateComponentContainer
コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
        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);
                }
            }
        }
コード例 #3
0
        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);
                    }
                }
            }
        }