wip
WHHHHYYYYYYY NOT WORK?!?!?
This commit is contained in:
@@ -27,6 +27,24 @@ namespace RH_Engine
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static string GetSessionID(string msg, PC[] PCs)
|
||||
{
|
||||
dynamic jsonData = JsonConvert.DeserializeObject(msg);
|
||||
Newtonsoft.Json.Linq.JArray data = jsonData.data;
|
||||
foreach (dynamic d in data)
|
||||
{
|
||||
foreach(PC pc in PCs)
|
||||
{
|
||||
if (d.clientinfo.host == pc.host && d.clientinfo.user == pc.user)
|
||||
{
|
||||
return d.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace RH_Engine
|
||||
|
||||
internal class Program
|
||||
{
|
||||
private static PC[] PCs = {
|
||||
private static PC[] PCs = {
|
||||
new PC("DESKTOP-M2CIH87", "Fabian"),
|
||||
new PC("T470S", "Shinichi"),
|
||||
new PC("NA", "Sem"),
|
||||
@@ -20,13 +20,11 @@ namespace RH_Engine
|
||||
{
|
||||
TcpClient client = new TcpClient("145.48.6.10", 6666);
|
||||
|
||||
WriteTextMessage(client, "{\r\n\"id\" : \"session/list\"\r\n}");
|
||||
string result = ReadPrefMessage(client.GetStream());
|
||||
JSONParser.Parse(result);
|
||||
CreateConnection(client.GetStream());
|
||||
|
||||
}
|
||||
|
||||
public static void WriteTextMessage(TcpClient client, string message)
|
||||
public static void WriteTextMessage(NetworkStream stream, string message)
|
||||
{
|
||||
byte[] msg = Encoding.ASCII.GetBytes(message);
|
||||
byte[] res = new byte[msg.Length + 4];
|
||||
@@ -34,7 +32,7 @@ namespace RH_Engine
|
||||
Array.Copy(BitConverter.GetBytes(msg.Length), 0, res, 0, 4);
|
||||
Array.Copy(msg, 0, res, 4, msg.Length);
|
||||
|
||||
client.GetStream().Write(res);
|
||||
stream.Write(res);
|
||||
|
||||
Console.WriteLine("sent message " + message);
|
||||
}
|
||||
@@ -48,19 +46,25 @@ namespace RH_Engine
|
||||
int length = BitConverter.ToInt32(lengthBytes);
|
||||
|
||||
byte[] buffer = new byte[length];
|
||||
int totalRead = 0;
|
||||
|
||||
int read = stream.Read(buffer, totalRead, buffer.Length - totalRead);
|
||||
totalRead += read;
|
||||
//Console.WriteLine("ReadMessage: " + read);
|
||||
//Console.WriteLine(Encoding.UTF8.GetString(buffer));
|
||||
int read = stream.Read(buffer, 0, buffer.Length);
|
||||
|
||||
|
||||
return Encoding.UTF8.GetString(buffer);
|
||||
}
|
||||
|
||||
private static void CreateTunnel()
|
||||
private static void CreateConnection(NetworkStream stream)
|
||||
{
|
||||
//WriteTextMessage(stream, "{\r\n\"id\" : \"session/list\"\r\n}");
|
||||
//string msg = ReadPrefMessage(stream);
|
||||
//Console.WriteLine(msg);
|
||||
//string id = JSONParser.GetSessionID(msg, PCs);
|
||||
|
||||
//Console.WriteLine(id);
|
||||
WriteTextMessage(stream, "{\r\n\"id\" : \"session/list\"\r\n}");
|
||||
string result = ReadPrefMessage(stream);
|
||||
Console.WriteLine(result);
|
||||
JSONParser.Parse(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user