ActorChat.Client.Program.ExecuteChatUserFlow C# (CSharp) Method

ExecuteChatUserFlow() static private method

static private ExecuteChatUserFlow ( this node, string roomName ) : Task
node this
roomName string
return Task
        async static Task ExecuteChatUserFlow(this ClientNode node, string roomName)
        {
            string name = Guid.NewGuid().ToString();


            JoinRoomResponse response = await node.SendRequestAsync<JoinRoomResponse>(
                new JoinRoom
                {
                    UserName = name,
                    RoomName = roomName
                });

            if (response.RetCode == JoinRoomRetCode.NameIsTaken)
            {
                Console.WriteLine("Name is taken");
                return;
            }

            Console.WriteLine("You are connected, say something or write 'exit' to quit");
            bool exit = false;

            while (!exit)
            {
                await Task.Yield(); //client uses single threaded processing, so it's better noto block it with Console.Readline
                string text = Console.ReadLine();
                if (text == "exit")
                {
                    exit = true;
                }
                else
                {
                    node.SendOneWay(new Say { Text = text });
                }
            }
        }
    }