示例#1
0
            public async Task GetAllBytes(ChunReq chunReq)
            {
                Log("***GetBytes chunks started  at:" + DateTime.Now);
                long start = DateTime.Now.Ticks;

                try
                {
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    using (var call = client.GetAllBytes(chunReq))
                    {
                        var      responseStream = call.ResponseStream;
                        FullFile fullFile       = null;
                        while (await responseStream.MoveNext())
                        {
                            fullFile = responseStream.Current;
                        }
                        // string responseString = Encoding.UTF8.GetString(responseBytes.ToArray());
                        sw.Stop();
                        long end  = DateTime.Now.Ticks;
                        long diff = end - start;
                        // File.WriteAllBytes("fullFileAllBytes.jpg", fullFile.AllBytes.ToByteArray());
                        Log("***GetAllBytes response finished  at:" + DateTime.Now + "took: " + sw.Elapsed);
                    }
                }
                catch (RpcException e)
                {
                    Log("RPC failed " + e);
                    throw;
                }
            }
示例#2
0
 public override async Task GetAllBytes(ChunReq request, IServerStreamWriter <FullFile> responseStream, ServerCallContext context)
 {
     FullFile fullFile = new FullFile()
     {
         AllBytes = ByteString.CopyFrom(testBytes)
     };
     await responseStream.WriteAsync(fullFile);
 }