private void Listen()
        {
            while (true)
            {
                Socket s = tcpListener.AcceptSocket();

                if (memReadout != null && songDetails != null && songDetails.IsValid())
                {
                    jsResp.success = true;
                }
                else
                {
                    jsResp.success = false;
                }

                try
                {
                    ServeClient(s);
                }
                catch (SocketException e)
                {
                    Logger.LogError("Unable to serve AddonService client");
                    Logger.LogException(e);
                }
                finally
                {
                    s.Dispose();
                }
            }
        }
示例#2
0
        private void OutputDetails()
        {
            //TODO: remember state of each file and only update the ones that have changed!
            foreach (OutputFile of in config.outputSettings.output)
            {
                //Clone the output text format so we can replace strings in it without changing the original
                string outputtext = (string)of.format.Clone();

                //Replace strings from song details
                outputtext = outputtext.Replace("%SONG_ID%", details.songID);
                outputtext = outputtext.Replace("%SONG_ARTIST%", details.artistName);
                outputtext = outputtext.Replace("%SONG_NAME%", details.songName);
                outputtext = outputtext.Replace("%SONG_ALBUM%", details.albumName);
                outputtext = outputtext.Replace("%ALBUM_YEAR%", details.albumYear.ToString());
                outputtext = outputtext.Replace("%SONG_LENGTH%", FormatTime(details.songLength));

                //Toolkit details
                if (details.toolkit != null)
                {
                    outputtext = outputtext.Replace("%TOOLKIT_VERSION%", details.toolkit.version);
                    outputtext = outputtext.Replace("%TOOLKIT_AUTHOR%", details.toolkit.author);
                    outputtext = outputtext.Replace("%TOOLKIT_PACKAGE_VERSION%", details.toolkit.package_version);
                    outputtext = outputtext.Replace("%TOOLKIT_COMMENT%", details.toolkit.comment);
                }

                //If this output contained song detail information
                if (outputtext != of.format)
                {
                    //And our current song details are not valid
                    if (!details.IsValid())
                    {
                        //Output nothing
                        outputtext = "";
                    }
                }

                var nd = memReadout.noteData ?? new LearnASongNoteData();

                //Replace strings from memory readout
                outputtext = outputtext.Replace("%SONG_TIMER%", FormatTime(memReadout.songTimer));
                outputtext = outputtext.Replace("%NOTES_HIT%", nd.TotalNotesHit.ToString());
                outputtext = outputtext.Replace("%CURRENT_STREAK%", (nd.CurrentHitStreak - nd.CurrentMissStreak).ToString());
                outputtext = outputtext.Replace("%HIGHEST_STREAK%", nd.HighestHitStreak.ToString());
                outputtext = outputtext.Replace("%NOTES_MISSED%", nd.TotalNotesMissed.ToString());
                outputtext = outputtext.Replace("%TOTAL_NOTES%", nd.TotalNotes.ToString());
                outputtext = outputtext.Replace("%CURRENT_ACCURACY%", FormatPercentage(nd.Accuracy));

                //Write to output
                WriteTextToFileLocking("output/" + of.filename, outputtext);
            }
        }
        private void Listen()
        {
            while (true)
            {
                Socket s = tcpListener.AcceptSocket();

                if (memReadout != null && songDetails != null && songDetails.IsValid())
                {
                    jsResp.success = true;
                }
                else
                {
                    jsResp.success = false;
                }

                ServeClient(s);
            }
        }
示例#4
0
        private void OutputDetails()
        {
            //Print memreadout if debug is enabled
            memReadout.print();

            //TODO: remember state of each file and only update the ones that have changed!
            foreach (OutputFile of in config.outputSettings.output)
            {
                //Clone the output text format so we can replace strings in it without changing the original
                string outputtext = (string)of.format.Clone();

                //Replace strings from song details
                outputtext = outputtext.Replace("%SONG_ARTIST%", details.artistName);
                outputtext = outputtext.Replace("%SONG_NAME%", details.songName);
                outputtext = outputtext.Replace("%SONG_ALBUM%", details.albumName);
                outputtext = outputtext.Replace("%ALBUM_YEAR%", details.albumYear.ToString());
                outputtext = outputtext.Replace("%SONG_LENGTH%", FormatTime(details.songLength));

                //If this output contained song detail information
                if (outputtext != of.format)
                {
                    //And our current song details are not valid
                    if (!details.IsValid())
                    {
                        //Output nothing
                        outputtext = "";
                    }
                }

                //Replace strings from memory readout
                outputtext = outputtext.Replace("%SONG_TIMER%", FormatTime(memReadout.songTimer));
                outputtext = outputtext.Replace("%NOTES_HIT%", memReadout.totalNotesHit.ToString());
                outputtext = outputtext.Replace("%CURRENT_STREAK%", (memReadout.currentHitStreak - memReadout.currentMissStreak).ToString());
                outputtext = outputtext.Replace("%HIGHEST_STREAK%", memReadout.highestHitStreak.ToString());
                outputtext = outputtext.Replace("%NOTES_MISSED%", memReadout.totalNotesMissed.ToString());
                outputtext = outputtext.Replace("%TOTAL_NOTES%", memReadout.TotalNotes.ToString());
                outputtext = outputtext.Replace("%CURRENT_ACCURACY%", FormatPercentage((memReadout.totalNotesHit > 0 && memReadout.TotalNotes > 0) ? ((double)memReadout.totalNotesHit / (double)memReadout.TotalNotes) : 0));

                //Write to output
                WriteTextToFileLocking("output/" + of.filename, outputtext);
            }
        }