Ejemplo n.º 1
0
 private void OnWebCrawl(object sender, InterpretEventArgs args)
 {
     _charName         = args.CharName;
     _currentLevel     = args.Level;
     _webCrawlFinished = true;
     Console.WriteLine("OnWebCrawl");
 }
Ejemplo n.º 2
0
        protected virtual void OnRaiseLevelEvent(InterpretEventArgs e)
        {
            EventHandler <InterpretEventArgs> handler = InterpreterEvent;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Ejemplo n.º 3
0
        public void Crawl(string fileToSave = null)
        {
            HttpClient client = new HttpClient();
            string     answer = client.GetStringAsync(_url).Result;

            if (fileToSave != null)
            {
                System.IO.File.WriteAllText(fileToSave, answer);
            }
            InterpretEventArgs interpreted = Interpreter.InterpretLine(answer);

            OnRaiseLevelEvent(interpreted);
        }
Ejemplo n.º 4
0
        private void CustomWatcher(string path)
        {
            running = true;
            while (running)
            {
                FileInfo fi = new FileInfo(ClientFile);
                //                Console.WriteLine(fi.Length);
                if (fi.Length > fileLength)
                {
                    FileInfo newFI = fi.CopyTo("ClientCopy", true);
                    using (FileStream fs = newFI.OpenRead())
                    {
                        fs.Seek(fileLength, SeekOrigin.Begin);
                        int size = (int)(fs.Length - fileLength);
                        if (size > 0)
                        {
                            byte[] data = new byte[size];
                            fs.Read(data, 0, size);
                            UTF8Encoding enc       = new UTF8Encoding(true);
                            string       addedLine = enc.GetString(data);
                            Console.WriteLine(addedLine);

                            InterpretEventArgs interpreted = LineInterpreter.InterpretLine(addedLine);
                            OnRaiseLevelEvent(interpreted);
                        }
                        else
                        {
                            Console.WriteLine("{0} nothing changed in {1}", DateTime.Now, path);
                        }
                    }
                }

                fileLength = fi.Length;
                Thread.Sleep(100);
            }
        }
Ejemplo n.º 5
0
 private void OnLevelUp(object sender, InterpretEventArgs args)
 {
     this._currentLevel = args.Level;
     Console.WriteLine("{0} is level {1}", _charName, _currentLevel);
 }
Ejemplo n.º 6
0
 private void OnGameRunning(object sender, InterpretEventArgs args)
 {
     _gameRunning = args.GameRunning;
 }
Ejemplo n.º 7
0
 private void OnGameRunning(object sender, InterpretEventArgs args)
 {
     _gameRunning = args.GameRunning;
     Console.WriteLine("OnGameRunning");
 }