//private int count = 0;

        private IEnumerator PutRequest(string Address)
        {
            var msgObj = gameStatus.GetStatusMsg();


            //var msgObj = new ActionMsg();
            //if (count == 5)
            //{
            //    msgObj.LevelID = "FeelingStronger";
            //    msgObj.Start = true;
            //}
            //count += 1;


            string msgJson = JsonUtility.ToJson(msgObj);

            byte[] msgData = System.Text.Encoding.UTF8.GetBytes(msgJson);

            using (UnityWebRequest req = UnityWebRequest.Put(Address, msgData))
            {
                req.SetRequestHeader("Content-type", "application/json; charset=UTF-8");

                // Send data and wait for the response
                yield return(req.SendWebRequest());

                if (req.isNetworkError)
                {
                    Logger.log.Debug("Network Error: " + req.error);
                }
                else
                {
                    //Logger.log.Debug("Received: " + req.downloadHandler.text);

                    if (allowChangeMap == true)
                    {
                        ActionMsg myObject = JsonUtility.FromJson <ActionMsg>(req.downloadHandler.text);
                        gameStatus.SetActionMsg(myObject);
                    }
                }
            }

            yield break;
        }
Пример #2
0
 public void SetActionMsg(ActionMsg msg)
 {
     SetLevel(msg.LevelID, msg.Start);
 }