Пример #1
0
        public void ProcessPacket() {
            if (CompletedPacket != null) {
                string packet = Encoding.ASCII.GetString(CompletedPacket);

                Data = new HttpWebServerRequestData(packet);

                if (ProcessRequest != null) {
                    this.ProcessRequest(this);
                }
            }
        }
Пример #2
0
        public void ProcessPacket() {
            if (CompletedPacket != null) {
                string packet = Encoding.ASCII.GetString(CompletedPacket);

                Data = new HttpWebServerRequestData(packet);

                if (ProcessRequest != null) {
                    FrostbiteConnection.RaiseEvent(ProcessRequest.GetInvocationList(), this);
                }
            }
        }
Пример #3
0
        public void ProcessPacket()
        {
            if (CompletedPacket != null)
            {
                string packet = Encoding.ASCII.GetString(CompletedPacket);

                Data = new HttpWebServerRequestData(packet);

                if (ProcessRequest != null)
                {
                    FrostbiteConnection.RaiseEvent(ProcessRequest.GetInvocationList(), this);
                }
            }
        }
Пример #4
0
        public void ProcessPacket()
        {
            if (CompletedPacket != null)
            {
                string packet = Encoding.ASCII.GetString(CompletedPacket);

                Data = new HttpWebServerRequestData(packet);

                if (ProcessRequest != null)
                {
                    this.ProcessRequest(this);
                }
            }
        }
Пример #5
0
        public override HttpWebServerResponseData OnHttpRequest(HttpWebServerRequestData data)
        {
            string responseString = "AdKats Remote: ";
            try
            {
                /*foreach (String key in data.POSTData.AllKeys)
                {
                    this.DebugWrite("POST Key: " + key + " val: " + data.Headers[key], 6);
                }*/
                foreach (String key in data.Query.AllKeys)
                {
                    this.DebugWrite("Query Key: " + key + " val: " + data.Query[key], 6);
                }
                this.DebugWrite("method: " + data.Method, 6);
                //this.DebugWrite("doc: " + data.Document, 6);
                AdKat_Record record = new AdKat_Record();
                record.command_source = AdKat_CommandSource.HTTP;

                NameValueCollection dataCollection = null;
                if (String.Compare(data.Method, "GET", true) == 0)
                {
                    dataCollection = data.Query;
                }
                else if (String.Compare(data.Method, "POST", true) == 0)
                {
                    return null;//dataCollection = data.POSTData;
                }
                string commandString = dataCollection["command_type"];
                record.command_type = this.getDBCommand(commandString);

                if (dataCollection["access_key"] != null && dataCollection["access_key"].Equals(this.externalCommandAccessKey))
                {
                    //If command not parsable, return without creating
                    if (record.command_type != AdKat_CommandType.Default)
                    {
                        //Set the command action
                        record.command_action = record.command_type;

                        //Set the source
                        string sourceName = dataCollection["source_name"];
                        if (!String.IsNullOrEmpty(sourceName))
                            record.source_name = sourceName;
                        else
                            record.source_name = "HTTPAdmin";

                        string duration = dataCollection["record_durationMinutes"];
                        if (duration != null && duration.Length > 0)
                        {
                            record.command_numeric = Int32.Parse(duration);
                        }
                        else
                        {
                            record.command_numeric = 0;
                        }

                        string message = dataCollection["record_message"];
                        if (!String.IsNullOrEmpty(message))
                        {
                            if (message.Length >= this.requiredReasonLength)
                            {
                                record.record_message = message;

                                //Check the target
                                string targetName = dataCollection["target_name"];
                                //Check for an exact match
                                if (!String.IsNullOrEmpty(targetName))
                                {
                                    record.target_name = targetName;
                                    responseString += this.completeTargetInformation(record, false);
                                }
                                else
                                {
                                    responseString += "target_name cannot be null";
                                }
                            }
                            else
                            {
                                responseString += "Reason too short. Needs to be at least " + this.requiredReasonLength + " chars.";
                            }
                        }
                        else
                        {
                            responseString += "record_message cannot be null.";
                        }
                    }
                    else
                    {
                        responseString += "Command '" + commandString + "' Not Parsable. Check AdKats doc for valid DB commands.";
                    }
                }
                else
                {
                    responseString += "access_key either not given or incorrect.";
                }
            }
            catch (Exception e)
            {
                responseString += e.ToString();
            }
            return new HttpWebServerResponseData(responseString);
        }
Пример #6
0
        public override HttpWebServerResponseData OnHttpRequest(HttpWebServerRequestData data)
        {
            String responseString = "AdKats Remote: ";
            try {
                foreach (String key in data.Query.AllKeys) {
                    this.DebugWrite("Query Key: " + key + " val: " + data.Query[key], 6);
                }
                this.DebugWrite("method: " + data.Method, 6);
                //this.DebugWrite("doc: " + data.Document, 6);
                AdKatsRecord record = new AdKatsRecord {
                                                           record_source = AdKatsRecord.Sources.HTTP
                                                       };

                NameValueCollection dataCollection = null;
                if (System.String.Compare(data.Method, "GET", System.StringComparison.OrdinalIgnoreCase) == 0) {
                    dataCollection = data.Query;
                }
                else if (System.String.Compare(data.Method, "POST", System.StringComparison.OrdinalIgnoreCase) == 0) {
                    return null; //dataCollection = data.POSTData;
                }
                if (dataCollection != null) {
                    String commandString = dataCollection["command_type"];
                    record.command_type = this._CommandKeyDictionary[commandString];

                    if (dataCollection["access_key"] != null && dataCollection["access_key"] == this._ExternalCommandAccessKey) {
                        //If command not parsable, return without creating
                        if (record.command_type != null) {
                            //Set the command action
                            record.command_action = record.command_type;

                            //Set the source
                            String sourceName = dataCollection["source_name"];
                            record.source_name = !String.IsNullOrEmpty(sourceName) ? sourceName : "HTTPAdmin";

                            String duration = dataCollection["record_durationMinutes"];
                            record.command_numeric = !string.IsNullOrEmpty(duration) ? Int32.Parse(duration) : 0;

                            String message = dataCollection["record_message"];
                            if (!String.IsNullOrEmpty(message)) {
                                if (message.Length >= this._RequiredReasonLength) {
                                    record.record_message = message;

                                    //Check the target
                                    String targetName = dataCollection["target_name"];
                                    //Check for an exact match
                                    if (!String.IsNullOrEmpty(targetName)) {
                                        record.target_name = targetName;
                                        this.CompleteTargetInformation(record, false);
                                        responseString += "Complete.";
                                    }
                                    else {
                                        responseString += "target_name cannot be null";
                                    }
                                }
                                else {
                                    responseString += "Reason too short. Needs to be at least " + this._RequiredReasonLength + " chars.";
                                }
                            }
                            else {
                                responseString += "record_message cannot be null.";
                            }
                        }
                        else {
                            responseString += "Command '" + commandString + "' Not Parsable. Check AdKats doc for valid DB commands.";
                        }
                    }
                    else {
                        responseString += "access_key either not given or incorrect.";
                    }
                }
            }
            catch (Exception e) {
                responseString += e.ToString();
            }
            return new HttpWebServerResponseData(responseString);
        }
Пример #7
0
        public override HttpWebServerResponseData OnHttpRequest(HttpWebServerRequestData data) {

            if (data.Query.Get("echo") != null) {
                return new HttpWebServerResponseData(data.Query.Get("echo"));
            }
            else {
                return new HttpWebServerResponseData("Hello World!");
            }
        }