Esempio n. 1
0
        private static void EnterMainLoop()
        {
            string Argument    = "";
            bool   exitProgram = false;

            ThePlayer.SongFinished += HandleSongFinished;

            while (!exitProgram)
            {
                string ln = Console.ReadLine();

                if (ln.StartsWith("/"))
                {
                    if (ln.StartsWith("/exit"))   //todo : yuck.
                    {
                        exitProgram = true;
                        continue;
                    }
                    CliCommandFactory.Execute(ThePlayer, ln);
                }
                else
                {
                    if (!string.IsNullOrEmpty(ln))
                    {
                        Subsonic.AddChatMessage(ln);
                    }
                }
                //todo : messages should be fetched async so we get more of a live chat idea
                //todo : i keep seeing the whole message log. this sucks
                IOrderedEnumerable <ChatMessage> messages = Subsonic.GetChatMessages(LastMsgDate).OrderBy(cm => cm.Date);

                foreach (var msg in messages)
                {
                    if (msg.Date >= LastMsgDate)
                    {
                        ConsoleUtils.UOut(ConsoleColor.Cyan, msg.ToString());
                    }
                }
                LastMsgDate = messages.Max(msg => msg.Date);
            }
            ThePlayer.Stop();
        }