Exemple #1
0
 public ExtendedResponse makeRequest(ExtendedCommand command)
 {
     if (!Connected)
     {
         return(null);
     }
     lock (this) {
         return(new ExtendedResponse(command, sendMessage(command.ToString())));
     }
 }
Exemple #2
0
        internal ExtendedResponse(ExtendedCommand command, string raw)
        {
            this.command = command;
            this.raw     = raw;
            this.decoded = HttpUtility.UrlDecode(raw);

            string commandStr = command.ToString();

            string commandBase = command.Base;

            valid = raw.StartsWith(commandBase, StringComparison.CurrentCultureIgnoreCase);

            if (valid)
            {
                Hashtable currentBucket = taggedParams;

                string[] responseParams = raw.Substring(HttpUtility.UrlEncode(commandStr).Length + 1).Split(new char[] { ' ' });

                for (int i = 0; i < responseParams.Length; i++)
                {
                    string decodedParam = HttpUtility.UrlDecode(responseParams[i]);

                    int sepPos = decodedParam.IndexOf(':');
                    if (sepPos == -1)
                    {
                        //bad data
                        continue;
                    }

                    string tag   = decodedParam.Substring(0, sepPos);
                    string value = decodedParam.Substring(sepPos + 1);

                    if (command.Delimeter.Equals(tag))
                    {
                        currentBucket = new Hashtable();
                        responses.Add(currentBucket);
                        currentBucket.Add(tag, value);
                    }
                    else
                    {
                        currentBucket.Add(tag, value);
                    }
                }
            }
            else
            {
                throw new InvalidResponseException("Response appears invalid", this);
            }
        }
Exemple #3
0
 internal ExtendedResponse(Player player, ExtendedCommand command, string raw) : this(command, raw)
 {
     this.player = player;
 }