Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ChatService.IChatService service = new ChatService.ChatServiceClient();

            Console.WriteLine("What is you're name?");
            String name = Console.ReadLine();


            Console.WriteLine("Loading messages...");

            ChatService.Message[] messages = service.GetMessages();
            PrintMessages(messages);

            String line = Console.ReadLine();
            while (!line.Equals("exit"))
            {
                ChatService.Message message = new ChatService.Message()
                {
                    Content = line,
                    User = name,
                };
                messages = service.SendMessage(message);
                PrintMessages(messages);
                line = Console.ReadLine();


            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            ChatService.IChatService service = new ChatService.ChatServiceClient();

            Console.WriteLine("Loading messages...");

            String[] messages =  service.GetMessages();
            PrintMessages(messages);

            String line = Console.ReadLine();
            while(!line.Equals("exit")){
                messages = service.SendMessage(line);
                PrintMessages(messages);
                line = Console.ReadLine();

            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            string host = "localhost";
            //host = "34.229.211.196";

            Channel channel = new Channel(host + ":32000", ChannelCredentials.Insecure);


            var id = new IdentityService.IdentityServiceClient(channel);

            Console.WriteLine("Key:");
            var k = Console.ReadLine();

            Console.WriteLine("Password:"******"Already exists.");
            }

            var authorization = id.ValidateIdentity(new ValidateIdentityRequest {
                Key = k, Passcode = v
            });

            Console.WriteLine(authorization);


            var client = new ChatService.ChatServiceClient(channel);

            Console.WriteLine("listening");
            using (var call = client.Listen(new ListenRequest()
            {
                SessionToken = Guid.NewGuid().ToString()
            }))
            {
                var receiverTask = Task.Run(async() =>
                {
                    while (await call.ResponseStream.MoveNext())
                    {
                        var message = call.ResponseStream.Current;
                        Console.WriteLine(message);
                    }
                });

                string newMessage;
                do
                {
                    newMessage = Console.ReadLine();
                    client.SendMessage(new SendMessageRequest {
                        Message      = newMessage,
                        SessionToken = authorization.SessionToken
                    });
                }while (!string.IsNullOrEmpty(newMessage));
            }

            // axicli identity login
            // axicli chat [channel] [message ...]

            channel.ShutdownAsync().Wait();
        }