Beispiel #1
0
        public void LoadResponse(string path, string data)
        {
            string shortpath = path.Substring(path.LastIndexOf("/kcsapi/") + 8);

            try
            {
                Utility.Logger.Add(1, "Recieved response:" + shortpath);

                SystemEvents.UpdateTimerEnabled = false;


                var json = DynamicJson.Parse(data.Substring(7));                        //remove "svdata="

                int result = (int)json.api_result;
                if (result != 1)
                {
                    if (result == 201)
                    {
                        Utility.Logger.Add(3,
                                           "Error code 201 was received. It may be triggered by macro detection " +
                                           "or by starting KanColle from another device.");
                    }
                    else
                    {
                        throw new InvalidOperationException($"Error code {result} was received from the server.");
                    }
                }


                if (shortpath == "api_get_member/ship2")
                {
                    ResponseReceived(shortpath, json);
                    APIList.OnResponseReceived(shortpath, json);
                }
                else if (json.IsDefined("api_data"))
                {
                    ResponseReceived(shortpath, json.api_data);
                    APIList.OnResponseReceived(shortpath, json.api_data);
                }
                else
                {
                    ResponseReceived(shortpath, null);
                    APIList.OnResponseReceived(shortpath, null);
                }
            }
            catch (Exception ex)
            {
                ErrorReporter.SendErrorReport(ex,
                                              "There was an error while receiving the response.",
                                              shortpath, data);
            }
            finally
            {
                SystemEvents.UpdateTimerEnabled = true;
            }
        }
Beispiel #2
0
        public void LoadResponse(string path, string data)
        {
            string shortpath = path.Substring(path.LastIndexOf("/kcsapi/") + 8);

            try
            {
                Utility.Logger.Add(1, "Responseを受信しました : " + shortpath);

                SystemEvents.UpdateTimerEnabled = false;


                var json = DynamicJson.Parse(data.Substring(7));                        //remove "svdata="

                int result = (int)json.api_result;
                if (result != 1)
                {
                    throw new InvalidOperationException("猫を検出しました。(エラーコード: " + result + ")");
                }


                if (shortpath == "api_get_member/ship2")
                {
                    ResponseReceived(shortpath, json);
                    APIList.OnResponseReceived(shortpath, json);
                }
                else if (json.IsDefined("api_data"))
                {
                    ResponseReceived(shortpath, json.api_data);
                    APIList.OnResponseReceived(shortpath, json.api_data);
                }
                else
                {
                    ResponseReceived(shortpath, null);
                    APIList.OnResponseReceived(shortpath, null);
                }
            }
            catch (Exception ex)
            {
                ErrorReporter.SendErrorReport(ex, "Responseの受信中にエラーが発生しました。", shortpath, data);
            }
            finally
            {
                SystemEvents.UpdateTimerEnabled = true;
            }
        }
        public void LoadResponse(string path, string data)
        {
            string shortpath = path.Substring(path.LastIndexOf("/kcsapi/") + 8);

            try {
                //Utility.Logger.Add( 1, LoggerRes.RecievedResponse + shortpath );

                SystemEvents.UpdateTimerEnabled = false;


                var json = DynamicJson.Parse(data.Substring(7));                                //remove "svdata="

                int result = (int)json.api_result;
                if (result != 1)
                {
                    var ex = new ArgumentException(LoggerRes.ResponseHadErrorCode + result);
                    Utility.ErrorReporter.SendErrorReport(ex, LoggerRes.ResponseHadErrorCode);
                    throw ex;
                }


                if (shortpath == "api_get_member/ship2")
                {
                    APIList.OnResponseReceived(shortpath, json);
                }
                else if (json.IsDefined("api_data"))
                {
                    APIList.OnResponseReceived(shortpath, json.api_data);
                }
                else
                {
                    APIList.OnResponseReceived(shortpath, null);
                }
            } catch (Exception ex) {
                ErrorReporter.SendErrorReport(ex, LoggerRes.ResponseError, shortpath, data);
            } finally {
                SystemEvents.UpdateTimerEnabled = true;
            }
        }