Esempio n. 1
0
        private void ModeSelection(string message)
        {
            var serverMessage = communication.data.ToString();

            if (serverMessage == "Enter name of chat" || serverMessage == "Enter user name")
            {
                FindGroup();
                OpenChat();
            }
            else if (serverMessage == "If you want to join a group write: join\n\r" +
                     "if you want to look at the invitations, write: look")
            {
                if (AcceptTheInvitation())
                {
                    OpenChat();
                }
                else
                {
                    EndUsing = true;
                }
            }
            else if (serverMessage == "You exit messanger")
            {
                EndUsing = true;
            }
            else
            {
                if (message.Length > 3 && message[0] == '?' && message[1] == '/')
                {
                    var first4 = message.Substring(0, 4);
                    SendMessage("I am waiting");
                    if (message == "?/ng")
                    {
                        var needOpenChat = CreateNewGroup();
                        if (needOpenChat)
                        {
                            OpenChat();
                        }
                        else
                        {
                            EndUsing = true;
                        }
                    }
                    else if (first4 == "?/gg")
                    {
                        writerGroups.Run(4);
                    }
                    else if (first4 == "?/cc")
                    {
                        writerGroups.Run(6);
                    }
                    else if (first4 == "?/pp" || first4 == "?/ch" || first4 == "?/sg" || first4 == "?/ug" || first4 == "?/ii" || first4 == "?/pg")
                    {
                        writerGroups.Run(1);
                    }
                    AnswerAndWriteServer();
                }
            }
        }
Esempio n. 2
0
        public bool Run()
        {
            Entrance entrance         = new Entrance(communication, @"D:\temp\User\user.json", writerGroups);
            var      successConection = entrance.ModeSelection();

            if (!successConection)
            {
                return(false);
            }
            writerGroups.Run(6);
            ConnectorToChat connectorToChat = new ConnectorToChat(communication, writerGroups);

            connectorToChat.SelectChat();
            Console.ReadKey(true);
            return(successConection);
        }