示例#1
0
文件: AdKats.cs 项目: LmaA-aD/AdKats
 private void request_RequestError(MetabansRequest sender) {
     if (Debug == enumBoolOnOff.On && ExecuteCommand != null) {
         ExecuteCommand("procon.protected.pluginconsole.write", "^1Metabans API request_RequestError: " + sender.Error);
     }
 }
示例#2
0
文件: AdKats.cs 项目: LmaA-aD/AdKats
            public MetabansAPI Post() {
                var request = new MetabansRequest(MetabansAPI.METABANS_API_HREF);
                request.RequestComplete += new MetabansRequest.RequestEventDelegate(request_RequestComplete);
                request.RequestError += new MetabansRequest.RequestEventDelegate(request_RequestError);
                request.Method = "POST";
                request.RequestContent = GeneratePostData();

                if (Debug == enumBoolOnOff.On && ExecuteCommand != null) {
                    ExecuteCommand("procon.protected.pluginconsole.write", "^4Metabans API: Post " + Uri.EscapeUriString(request.RequestContent));
                }

                request.BeginRequest();

                return this;
            }
示例#3
0
文件: AdKats.cs 项目: LmaA-aD/AdKats
            private void request_RequestComplete(MetabansRequest sender) {
                var table = (Hashtable) JSON.JsonDecode(Encoding.UTF8.GetString(sender.CompleteFileData));

                try {
                    if (Debug == enumBoolOnOff.On && ExecuteCommand != null) {
                        ExecuteCommand("procon.protected.pluginconsole.write", "^4Metabans API: Received sync response, beginning parse");
                    }

                    foreach (Hashtable response in (ArrayList) table["responses"]) {
                        if (response.ContainsKey("status") == true && (string) response["status"] == "OK") {
                            if (response.ContainsKey("request") == true && response.ContainsKey("data") == true) {
                                var request = (Hashtable) response["request"];
                                var data = (Hashtable) response["data"];

                                if (request.ContainsKey("action") == true) {
                                    switch ((string) request["action"]) {
                                        case "mb_sight_player":
                                            if (mb_sight_player_ok != null) {
                                                mb_sight_player_ok(request, data);
                                            }
                                            break;
                                        case "mb_assess_player":
                                            if (mb_assess_player_ok != null) {
                                                mb_assess_player_ok(request, data);
                                            }
                                            break;
                                    }
                                }
                            }
                        }
                        else if (response.ContainsKey("error") == true) {
                            if ( /*this.Debug == enumBoolOnOff.On && */ExecuteCommand != null) {
                                // This is an error because of information sent to the metabans (like api key error or something)
                                // not an actual problem that requires debugging.
                                ExecuteCommand("procon.protected.pluginconsole.write", "^1Metabans API: Response error; " + (string) ((Hashtable) response["error"])["message"]);
                            }
                        }
                    }

                    if (Debug == enumBoolOnOff.On && ExecuteCommand != null) {
                        ExecuteCommand("procon.protected.pluginconsole.write", "^4Metabans API: Received sync and parse completed");
                    }
                }
                catch (Exception e) {
                    if (Debug == enumBoolOnOff.On && ExecuteCommand != null) {
                        ExecuteCommand("procon.protected.pluginconsole.write", "^1Metabans API (request_RequestComplete): " + e.Message);
                    }
                }
            }