Example #1
0
        public async Task OnServerStream(string p_title)
        {
            var reader = await AtTestRpc.OnServerStream(p_title);

            while (await reader.MoveNext())
            {
                Log.Information("客户端读取:" + reader.Val <string>());
            }
            Log.Information("服务端写入结束");
        }
Example #2
0
        public async Task OnDuplexStream(string p_title)
        {
            var duplex = await AtTestRpc.OnDuplexStream(p_title);

            for (int i = 0; i < 50; i++)
            {
                var msg = $"{p_title} {i}";
                await duplex.RequestWriter.Write(msg);

                Log.Information("客户端写入:" + msg);

                if (await duplex.ResponseReader.MoveNext())
                {
                    Log.Information("客户端读取:" + duplex.ResponseReader.Val <string>());
                }
                await Task.Delay(1000);
            }
        }
Example #3
0
        public async Task OnClientStream(string p_title = "hello")
        {
            var writer = await AtTestRpc.OnClientStream(p_title);

            int i = 0;

            while (true)
            {
                var msg = $"{p_title} {i++}";
                if (!await writer.Write(msg) || i > 50)
                {
                    break;
                }
                Log.Information("客户端写入:" + msg);
                await Task.Delay(1000);
            }
            writer.Complete();
        }
Example #4
0
 public Task <bool> SetString(string p_str)
 {
     return(AtTestRpc.SetString(p_str));
 }
Example #5
0
 public Task <string> GetString()
 {
     return(AtTestRpc.GetString());
 }