Parser erkennt nun ob Paket vollständig ist
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace WorldOfPeacecraft
|
||||
{
|
||||
@@ -10,11 +11,13 @@ namespace WorldOfPeacecraft
|
||||
private AutoResetEvent BufferFilledEvent = new AutoResetEvent (false);
|
||||
private Thread ParserThread;
|
||||
private List<string> message;
|
||||
private Regex LastLineRegex;
|
||||
|
||||
public Parser ()
|
||||
{
|
||||
ParserThread = new Thread (new ThreadStart (this.RunParser));
|
||||
message = new LinkedList<string> ();
|
||||
LastLineRegex = new Regex("^end:[0-9]+$");
|
||||
}
|
||||
|
||||
public void RunParser ()
|
||||
@@ -35,11 +38,20 @@ namespace WorldOfPeacecraft
|
||||
}
|
||||
}
|
||||
|
||||
public static void Parse (List<string> message)
|
||||
public void Parse ()
|
||||
{
|
||||
// If package is not complete wait for more lines
|
||||
if (!IsCompletePackage())
|
||||
return;
|
||||
// TODO Implement
|
||||
}
|
||||
|
||||
public bool IsCompletePackage()
|
||||
{
|
||||
string lastLine = message.Last.Value;
|
||||
return LastLineRegex.IsMatch(lastLine);
|
||||
}
|
||||
|
||||
public void Stop ()
|
||||
{
|
||||
ParserThread.Abort ();
|
||||
|
||||
Reference in New Issue
Block a user