Server is now able to read data and confirm data it received.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -46,10 +47,52 @@ namespace ErgometerServer
|
|||||||
TcpClient client = obj as TcpClient;
|
TcpClient client = obj as TcpClient;
|
||||||
StreamReader reader = new StreamReader(client.GetStream(), Encoding.ASCII);
|
StreamReader reader = new StreamReader(client.GetStream(), Encoding.ASCII);
|
||||||
StreamWriter stream = new StreamWriter(client.GetStream(), Encoding.ASCII);
|
StreamWriter stream = new StreamWriter(client.GetStream(), Encoding.ASCII);
|
||||||
string q = reader.ReadLine();
|
string name = null;
|
||||||
if(q == "1«")
|
int session = 0;
|
||||||
Console.WriteLine(q);
|
bool doctor;
|
||||||
|
string a = reader.ReadLine();
|
||||||
|
Console.WriteLine(a);
|
||||||
|
if (a.StartsWith("1»") && a.EndsWith("connect"))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Connection established");
|
||||||
|
stream.WriteLine(a.Substring(0, a.Length - 7) + "cs");
|
||||||
|
}
|
||||||
|
string b = reader.ReadLine();
|
||||||
|
if (b.StartsWith("2»"))
|
||||||
|
{
|
||||||
|
Console.WriteLine(b);
|
||||||
|
string[] package = b.Split('»');
|
||||||
|
name = package[2];
|
||||||
|
session = int.Parse(package[1]);
|
||||||
|
doctor = package[3].Equals("doctor");
|
||||||
|
if (doctor)
|
||||||
|
{
|
||||||
|
//check password
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("login of " + name + " succesful");
|
||||||
|
stream.WriteLine("2»" + package[1] + "»client»ls");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
string c = reader.ReadLine();
|
||||||
|
ArrayList data = new ArrayList();
|
||||||
|
while (c.StartsWith("3»"))
|
||||||
|
{
|
||||||
|
Console.WriteLine(c);
|
||||||
|
data.Add(c);
|
||||||
|
stream.WriteLine("3»" + session + "»succes");
|
||||||
|
c = reader.ReadLine();
|
||||||
|
}
|
||||||
|
string d = reader.ReadLine();
|
||||||
|
ArrayList oldData = new ArrayList();
|
||||||
|
while (c.StartsWith("4»"))
|
||||||
|
{
|
||||||
|
Console.WriteLine(d);
|
||||||
|
oldData.Add(d);
|
||||||
|
stream.WriteLine("4»" + session + "»succes");
|
||||||
|
d = reader.ReadLine();
|
||||||
|
}
|
||||||
stream.Flush();
|
stream.Flush();
|
||||||
stream.Close();
|
stream.Close();
|
||||||
reader.Close();
|
reader.Close();
|
||||||
|
|||||||
Reference in New Issue
Block a user