SaveData
This commit is contained in:
@@ -14,12 +14,14 @@ namespace Server
|
||||
private byte[] buffer = new byte[1024];
|
||||
private byte[] totalBuffer = new byte[1024];
|
||||
private int totalBufferReceived = 0;
|
||||
private SaveData saveData;
|
||||
|
||||
|
||||
public string Username { get; set; }
|
||||
|
||||
public Client(Communication communication, TcpClient tcpClient)
|
||||
{
|
||||
this.saveData = new SaveData();
|
||||
this.communication = communication;
|
||||
this.tcpClient = tcpClient;
|
||||
this.stream = this.tcpClient.GetStream();
|
||||
@@ -75,11 +77,12 @@ namespace Server
|
||||
Array.Copy(message, 5, jsonArray, 0, message.Length - 5);
|
||||
dynamic json = JsonConvert.DeserializeObject(Encoding.ASCII.GetString(jsonArray));
|
||||
Console.WriteLine(json);
|
||||
saveData.WriteData(Encoding.ASCII.GetString(jsonArray));
|
||||
|
||||
}
|
||||
else if (message[4] == 0x02)
|
||||
{
|
||||
|
||||
Console.WriteLine(message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
22
Server/SaveData.cs
Normal file
22
Server/SaveData.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user