-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathProgram.cs
More file actions
39 lines (31 loc) · 1.28 KB
/
Copy pathProgram.cs
File metadata and controls
39 lines (31 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using GameService;
using Grpc.Core;
using System;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace ChatClient
{
class Program
{
static async Task Main(string[] args)
{
Environment.SetEnvironmentVariable("GRPC_TRACE", "api,http,cares_resolver,cares_address_sorting,transport_security,tsi");
Environment.SetEnvironmentVariable("GRPC_VERBOSITY", "debug");
Grpc.Core.GrpcEnvironment.SetLogger(new Grpc.Core.Logging.ConsoleLogger());
var channel = new Channel("localhost:50051", ChannelCredentials.Insecure);
var client = new GameChat.ChatService.ChatServiceClient(channel);
int cnt = 0;
using (var call = client.CreateRoom(new GameChat.CreateRoomRequest { RoomName = "testroom", SenderName = "testuser" }))
{
var responseStream = call.ResponseStream;
while (await responseStream.MoveNext())
{
await client.SendChatAsync(new GameChat.SendChatRequest() { RoomId = responseStream.Current.RoomId, Message = $"test {cnt++}" });
}
}
await channel.ShutdownAsync();
}
}
}