コード例 #1
0
        private void UnexpectedResponse(Response.Types responseType, Request.Types requestType)
        {
            string ex = string.Format(
                "Unexpected {0} response for request {1}.",
                responseType,
                requestType
                );

            throw new Exception(ex);
        }
コード例 #2
0
        private Response ReadResponse(NetworkStream stream)
        {
            BinaryReader r = new BinaryReader(stream);

            Response.Types responseType   = (Response.Types)r.ReadByte();
            int            responseLength = IPAddress.NetworkToHostOrder(r.ReadInt32());

            if (responseLength > MaxLength)
            {
                throw new Exception(
                          "SendMessage got a response that exceeded max length");
            }
            byte[] responseData = new byte[0];
            if (responseLength > 0)
            {
                responseData = r.ReadBytes(responseLength);
            }

            return(new Response(responseType, responseData));
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: MinikPLayer/6obcyManager
        static void ParseString(string line)
        {
            Response.Types type = Response.ParseType(line[0]);
            line = line.Remove(0, 1);

            string source, response;

            source = response = "";
            bool quote = false;
            bool part  = false;

            for (int i = 0; i < line.Length; i++)
            {
                if (line[i] == '\"')
                {
                    quote = !quote;
                    continue;
                }
                if (!quote && line[i] == ':')
                {
                    part = true;
                    continue;
                }

                if (quote)
                {
                    if (part)
                    {
                        response += line[i];
                    }
                    else
                    {
                        source += line[i];
                    }
                }
            }

            responses.Add(new Response {
                source = source, response = response, type = type
            });
        }