Exemple #1
0
        public Stream EchoStream(Stream data)
        {
            Console.WriteLine($"[EchoStream]...Received length:{data.Length}, {Helper.ReadStr(data)}...Send TestFile.txt");
            var stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

            return(stream);
        }
Exemple #2
0
        private static void Test_GetComplexStream()
        {
            Console.Write("[GetComplexStream]...");
            var complexStream = _proxy.GetComplexStream();

            using (var stream = complexStream.Stream)
                Console.WriteLine($"length:{stream.Length}, {Helper.ReadStr(stream)}");
            Console.WriteLine($", otherInfo:{complexStream.OtherInfo}");
        }
Exemple #3
0
        private static async Task Test_GetComplexStreamAsync()
        {
            Console.Write("[GetComplexStreamAsync]...");
            var complexStream = await _proxyAsync.GetComplexStreamAsync();

            using (var stream = complexStream.Stream)
                Console.WriteLine($"length:{stream.Length}, {Helper.ReadStr(stream)}");
            Console.WriteLine($", otherInfo:{complexStream.OtherInfo}");
        }
Exemple #4
0
 private static void Test_EchoStream()
 {
     using (var stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
     {
         Console.Write("[EchoStream]...Send TestFile.txt...");
         var data = _proxy.EchoStream(stream);
         Console.WriteLine($"Received length:{data.Length}, {Helper.ReadStr(data)}");
     }
 }
Exemple #5
0
        private static async Task Test_EchoStreamAsync()
        {
            using (var stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                Console.Write("[EchoStreamAsync]...Send TestFile.txt...");
                var data = await _proxyAsync.EchoStreamAsync(stream);

                Console.WriteLine($"Received length:{stream.Length}, {Helper.ReadStr(data)}");
            }
        }
Exemple #6
0
        public async Task PostAsync(string s1, Stream data)
        {
            Console.Write($"Receive: {s1}, stream:{Helper.ReadStr(data)}, start...");
            for (var i = 0; i < 3; i++)
            {
                await Task.Delay(1000);

                Console.Write($"{i}, ");
            }

            Console.WriteLine("end");
        }
Exemple #7
0
        private static async Task Test_ComplexCallAsync()
        {
            using (var stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                Console.Write("[ComplexCallAsync]...Send TestFile.txt...");
                var complexStream = await _c1.Proxy.ComplexCallAsync(
                    new CustomObj { Date = DateTime.Now, Name = "ComplexCall" },
                    stream,
                    async i => Console.Write(", " + i.Progress),
                    default);

                using (var stream2 = complexStream.Stream)
                    Console.Write($", receive length:{stream.Length}, {Helper.ReadStr(stream2)}");
                Console.WriteLine($", otherInfo:{complexStream.OtherInfo}");
            }
        }
Exemple #8
0
        public async Task <Ret> Call(InParam p, int i, Stream stream, Func <int, Task> progs, CancellationToken token)
        {
            Console.WriteLine($"{p}, {i}, {Helper.ReadStr(stream)}");

            for (var i1 = 0; i1 < 3; i1++)
            {
                await progs(i1);

                await Task.Delay(100, token);
            }

            return(new Ret
            {
                Stream = File.OpenRead(Helper.GetTestFilePath()),
                P1 = "return p1"
            });
        }
Exemple #9
0
        public async Task <ComplexStream> ComplexCallAsync(CustomObj obj, Stream data, Func <CustomCallbackObj, Task> cb, CancellationToken token)
        {
            Console.Write($"[ComplexCallAsync]...Received length:{data.Length}, {Helper.ReadStr(data)}, ");
            for (var i = 1; i <= 3; i++)
            {
                Console.Write($"{i}, ");
                await cb(new CustomCallbackObj { Progress = i });

                await Task.Delay(100, token);
            }

            Console.WriteLine("...Send TestFile.txt");
            return(new ComplexStream
            {
                Stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite),
                OtherInfo = "this is other info"
            });
        }
Exemple #10
0
        public ComplexStream ComplexCall(CustomObj obj, Stream data, Func <CustomCallbackObj, Task> cb)
        {
            Console.Write($"[ComplexCall]...Received length:{data.Length}, {Helper.ReadStr(data)}, ");
            for (var i = 1; i <= 3; i++)
            {
                Console.Write($"{i}, ");
                cb(new CustomCallbackObj {
                    Progress = i
                });
                Task.Delay(100).Wait();
            }

            Console.WriteLine("...Send TestFile.txt");
            return(new ComplexStream
            {
                Stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite),
                OtherInfo = "this is other info"
            });
        }
Exemple #11
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            try
            {
                var ret = await _s1.Call(new InParam { P1 = "123" }, 100, File.OpenRead(Helper.GetTestFilePath()),
                                         async i => Console.WriteLine(i), CancellationToken.None);

                Console.WriteLine($"ret:{ret.P1}, {Helper.ReadStr(ret.Stream)}");

                using (var fs = File.OpenWrite(@"d:\1.rar"))
                {
                    ret.Stream.CopyTo(fs);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemple #12
0
 public void SetStream(Stream data)
 {
     Console.WriteLine($"[SetStream]...length:{data.Length}, {Helper.ReadStr(data)}");
 }
Exemple #13
0
 private static async Task Test_GetStreamAsync()
 {
     Console.Write("[GetStreamAsync]...");
     using (var stream = await _proxyAsync.GetStreamAsync())
         Console.WriteLine($"length:{stream.Length}, {Helper.ReadStr(stream)}");
 }
Exemple #14
0
 private static void Test_GetStream()
 {
     Console.Write("[GetStream]...");
     using (var stream = _proxy.GetStream())
         Console.WriteLine($"length:{stream.Length}, {Helper.ReadStr(stream)}");
 }