Merge branch 'develop' of https://github.com/SemvdH/Proftaak-RH-B4 into develop
This commit is contained in:
@@ -40,6 +40,7 @@ namespace RH_Engine
|
||||
{
|
||||
if (d.clientinfo.host == pc.host && d.clientinfo.user == pc.user)
|
||||
{
|
||||
Console.WriteLine("connecting to {0}, on {1} with id {2}", pc.user, pc.host, d.id);
|
||||
return d.id;
|
||||
}
|
||||
}
|
||||
@@ -48,6 +49,16 @@ namespace RH_Engine
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetTunnelID(string json)
|
||||
{
|
||||
dynamic jsonData = JsonConvert.DeserializeObject(json);
|
||||
if (jsonData.data.status == "ok")
|
||||
{
|
||||
return jsonData.data.id;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,20 +65,28 @@ namespace RH_Engine
|
||||
|
||||
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);
|
||||
foreach (var s in JSONParser.GetUsers(result))
|
||||
{
|
||||
Console.WriteLine(s);
|
||||
}
|
||||
string id = JSONParser.GetSessionID(ReadPrefMessage(stream), PCs);
|
||||
|
||||
string tunnelCreate = "{\"id\" : \"tunnel/create\", \"data\" : {\"session\" : \"" + id + "\"}}";
|
||||
|
||||
WriteTextMessage(stream, tunnelCreate);
|
||||
|
||||
string tunnelResponse = ReadPrefMessage(stream);
|
||||
|
||||
Console.WriteLine(tunnelResponse);
|
||||
|
||||
string tunnelID = JSONParser.GetTunnelID(tunnelResponse);
|
||||
Console.WriteLine("tunnelID is: " + tunnelID);
|
||||
|
||||
string sceneReset = "{\"id\" : \"tunnel/send\", \"data\" : {\"dest\" : \"" + tunnelID + "\",\"data\" :{\"id\" : \"scene/reset\",\"data\" : { }}}}}";
|
||||
//string sceneReset = "{\"id\" : \"scene/reset\"}";
|
||||
|
||||
WriteTextMessage(stream, sceneReset);
|
||||
|
||||
Console.WriteLine(ReadPrefMessage(stream));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user