Exemplo n.º 1
0
        static void SendSync()
        {
            string       userInput = InputString("Data:", "some data", false);
            SyncResponse resp      = _Mesh.SendAndWait(
                InputString("IP:Port", "127.0.0.1:8000", false),
                InputInteger("Timeout ms:", 15000, true, false),
                userInput);

            if (resp != null)
            {
                Console.WriteLine("Status: " + resp.Status.ToString());
                if (resp.ContentLength > 0)
                {
                    if (resp.DataStream != null)
                    {
                        if (resp.DataStream.CanRead)
                        {
                            Console.WriteLine("Response: " + Encoding.UTF8.GetString(ReadStream(resp.ContentLength, resp.DataStream)));
                        }
                        else
                        {
                            Console.WriteLine("Cannot read from response stream");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Response stream is null");
                    }
                }
                else
                {
                    Console.WriteLine("(null)");
                }
            }
            else
            {
                Console.WriteLine("Failed");
            }
        }