Beispiel #1
0
        /// <summary>
        /// Парсит данные от сервера
        /// </summary>
        /// <param name="data"></param>
        private void ParseInputData(string data)
        {
            Logger.Log("input data:{0}", data);
            var response = new NetResponse(data);
            var method = response.GetMethod;
            //Logger.Log("input data method:{0}", method.ToString());

            if (response.IsError)
            {
                Logger.Log("[Server Error]{0}", response.GetError);
            }

            switch(method)
            {
                case PacketTypes.auth:
                    if (OnAuthCompleted != null)
                    {
                        OnAuthCompleted(response);
                    }
                    break;
                case PacketTypes.gettask:
                case PacketTypes.sendtask:
                    if (OnSendTaskCompleted != null)
                    {
                        OnSendTaskCompleted(response);
                    }
                    break;
                default:
                    Logger.Log("Error parse: Packet haven't method!");
                    break;
            }
        }
Beispiel #2
0
 private void OnSendTaskCompletedCallback(NetResponse response)
 {
     if (!response.IsError)
     {
         if (response.IsContainsKey("task"))
         {
             var taskText = response.GetValue("task");
             var taskRank = double.Parse(response.GetValue("rank"));
             byte taskUserRank = 0;//load from localStorage
             List<Comment> taskComments = null;
             //if (response.IsContainsKey("comments"))
             //{
             //    taskComments = new List<Comment>();
             //    var comments = response.GetValue("comments").Split(new char[]{'|'});
             //    foreach(var comm in comments)
             //    {
             //        var commParam = comm.Split(new string[]{";1;"},StringSplitOptions.RemoveEmptyEntries);
             //    }
             //}
             _currentTask = new GameTask(taskText, taskRank, taskComments, taskUserRank);
         }
         else
         {
             _currentTask = null;
         }
         //CallDataUpdate();
     }
 }