Verwendung von StreamWriter im Sender

This commit is contained in:
2014-03-26 00:12:47 +01:00
parent 8261fa0051
commit 978f074617

View File

@@ -5,22 +5,21 @@ using System.Text;
public class Sender public class Sender
{ {
private NetworkStream NStream; private StreamWriter Writer;
private Terminal Term; private Terminal Term;
public Sender (NetworkStream stream, Terminal terminal) public Sender (NetworkStream stream, Terminal terminal)
{ {
this.Term = terminal; this.Term = terminal;
this.NStream = stream; this.Writer = new StreamWriter(stream);
} }
public void Send () public void Send ()
{ {
while (true) { while (true) {
String line = Term.ReadLine (); String line = Term.ReadLine ();
line += "\n"; Writer.WriteLine(line);
byte[] bytes = Encoding.UTF8.GetBytes(line); Writer.Flush();
NStream.Write (bytes, 0, bytes.Length);
} }
} }
} }