This commit is contained in:
fabjuuuh
2020-09-25 13:43:00 +02:00
parent d0071bd13c
commit cf9341a93e
2 changed files with 26 additions and 1 deletions

View File

@@ -14,12 +14,14 @@ namespace Server
private byte[] buffer = new byte[1024]; private byte[] buffer = new byte[1024];
private byte[] totalBuffer = new byte[1024]; private byte[] totalBuffer = new byte[1024];
private int totalBufferReceived = 0; private int totalBufferReceived = 0;
private SaveData saveData;
public string Username { get; set; } public string Username { get; set; }
public Client(Communication communication, TcpClient tcpClient) public Client(Communication communication, TcpClient tcpClient)
{ {
this.saveData = new SaveData();
this.communication = communication; this.communication = communication;
this.tcpClient = tcpClient; this.tcpClient = tcpClient;
this.stream = this.tcpClient.GetStream(); this.stream = this.tcpClient.GetStream();
@@ -75,11 +77,12 @@ namespace Server
Array.Copy(message, 5, jsonArray, 0, message.Length - 5); Array.Copy(message, 5, jsonArray, 0, message.Length - 5);
dynamic json = JsonConvert.DeserializeObject(Encoding.ASCII.GetString(jsonArray)); dynamic json = JsonConvert.DeserializeObject(Encoding.ASCII.GetString(jsonArray));
Console.WriteLine(json); Console.WriteLine(json);
saveData.WriteData(Encoding.ASCII.GetString(jsonArray));
} }
else if (message[4] == 0x02) else if (message[4] == 0x02)
{ {
Console.WriteLine(message);
} }

22
Server/SaveData.cs Normal file
View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Server
{
class SaveData
{
public SaveData()
{
}
public void WriteData(string data)
{
using (StreamWriter sw = File.AppendText(Directory.GetCurrentDirectory() + "/data.txt"))
{
sw.WriteLine(data);
}
}
}
}