probably fixed the serials
This commit is contained in:
@@ -74,6 +74,7 @@ namespace RH_Engine
|
||||
dynamic payload = new
|
||||
{
|
||||
id = "scene/node/add",
|
||||
serial = "needResponse",
|
||||
data = new
|
||||
{
|
||||
name = "newNode",
|
||||
@@ -106,11 +107,12 @@ namespace RH_Engine
|
||||
|
||||
}
|
||||
|
||||
public string addPanel()
|
||||
public string addPanel(string serialToSend)
|
||||
{
|
||||
dynamic payload = new
|
||||
{
|
||||
id = "scene/node/add",
|
||||
serial = serialToSend,
|
||||
data = new
|
||||
{
|
||||
name = "dashboard",
|
||||
@@ -131,7 +133,36 @@ namespace RH_Engine
|
||||
return JsonConvert.SerializeObject(Payload(payload));
|
||||
}
|
||||
|
||||
public string bikeSpeed(string uuidPanel)
|
||||
public string ColorPanel(string uuidPanel)
|
||||
{
|
||||
dynamic payload = new
|
||||
{
|
||||
id = "scene/panel/setclearcolor",
|
||||
data = new
|
||||
{
|
||||
id = uuidPanel,
|
||||
color = new int[] { 1, 1, 1, 1 }
|
||||
}
|
||||
};
|
||||
|
||||
return JsonConvert.SerializeObject(Payload(payload));
|
||||
}
|
||||
|
||||
public string SwapPanel(string uuid)
|
||||
{
|
||||
dynamic payload = new
|
||||
{
|
||||
id = "scene/panel/swap",
|
||||
data = new
|
||||
{
|
||||
id = uuid
|
||||
}
|
||||
};
|
||||
|
||||
return JsonConvert.SerializeObject(Payload(payload));
|
||||
}
|
||||
|
||||
public string bikeSpeed(string uuidPanel, double speed)
|
||||
{
|
||||
dynamic payload = new
|
||||
{
|
||||
@@ -140,7 +171,7 @@ namespace RH_Engine
|
||||
{
|
||||
id = uuidPanel,
|
||||
text = "Bike speed placeholder",
|
||||
position = new int[] { 100, 100 },
|
||||
position = new int[] { 0, 0 },
|
||||
size = 32.0,
|
||||
color = new int[] { 0, 0, 0, 1 },
|
||||
font = "segoeui"
|
||||
@@ -180,20 +211,20 @@ namespace RH_Engine
|
||||
|
||||
public string AddBikeModel()
|
||||
{
|
||||
return AddModel("bike", "data\\NetworkEngine\\models\\bike\\bike.fbx");
|
||||
return AddModel("bike","addbike", "data\\NetworkEngine\\models\\bike\\bike.fbx");
|
||||
}
|
||||
|
||||
public string AddModel(string nodeName, string fileLocation)
|
||||
public string AddModel(string nodeName,string serial, string fileLocation)
|
||||
{
|
||||
return AddModel(nodeName, fileLocation, null, new float[] { 0, 0, 0 }, 1, new float[] { 0, 0, 0 });
|
||||
return AddModel(nodeName,serial, fileLocation, null, new float[] { 0, 0, 0 }, 1, new float[] { 0, 0, 0 });
|
||||
}
|
||||
|
||||
public string AddModel(string nodeName, string fileLocation, float[] positionVector, float scalar, float[] rotationVector)
|
||||
public string AddModel(string nodeName,string serial, string fileLocation, float[] positionVector, float scalar, float[] rotationVector)
|
||||
{
|
||||
return AddModel(nodeName, fileLocation, null, positionVector, scalar, rotationVector);
|
||||
return AddModel(nodeName,serial, fileLocation, null, positionVector, scalar, rotationVector);
|
||||
}
|
||||
|
||||
public string AddModel(string nodeName, string fileLocation, string animationLocation, float[] positionVector, float scalar, float[] rotationVector)
|
||||
public string AddModel(string nodeName,string serialToSend, string fileLocation, string animationLocation, float[] positionVector, float scalar, float[] rotationVector)
|
||||
{
|
||||
string namename = nodeName;
|
||||
bool animatedBool = false;
|
||||
@@ -205,6 +236,7 @@ namespace RH_Engine
|
||||
dynamic payload = new
|
||||
{
|
||||
id = "scene/node/add",
|
||||
serial = serialToSend,
|
||||
data = new
|
||||
{
|
||||
name = namename,
|
||||
@@ -257,14 +289,14 @@ namespace RH_Engine
|
||||
}
|
||||
|
||||
|
||||
public string RouteCommand()
|
||||
public string RouteCommand(string serialToSend)
|
||||
{
|
||||
ImprovedPerlin improvedPerlin = new ImprovedPerlin(4325, LibNoise.NoiseQuality.Best);
|
||||
Random r = new Random();
|
||||
dynamic payload = new
|
||||
{
|
||||
id = "route/add",
|
||||
serial = "route",
|
||||
serial = serialToSend,
|
||||
data = new
|
||||
{
|
||||
nodes = new dynamic[]
|
||||
|
||||
@@ -81,9 +81,9 @@ namespace RH_Engine
|
||||
public static string GetResponseUuid(string json)
|
||||
{
|
||||
dynamic jsonData = JsonConvert.DeserializeObject(json);
|
||||
if (jsonData.data.status == "ok")
|
||||
if (jsonData.data.data.status == "ok")
|
||||
{
|
||||
return jsonData.data.uuid;
|
||||
return jsonData.data.data.data.uuid;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@@ -14,7 +15,7 @@ using System.Threading;
|
||||
namespace RH_Engine
|
||||
{
|
||||
|
||||
public delegate void HandleSerial(string uuid);
|
||||
public delegate void HandleSerial(string message);
|
||||
internal class Program
|
||||
{
|
||||
private static PC[] PCs = {
|
||||
@@ -30,6 +31,8 @@ namespace RH_Engine
|
||||
private static ServerResponseReader serverResponseReader;
|
||||
private static string sessionId = string.Empty;
|
||||
private static string tunnelId = string.Empty;
|
||||
private static string routeId = string.Empty;
|
||||
private static string panelId = string.Empty;
|
||||
|
||||
private static Dictionary<string, HandleSerial> serialResponses = new Dictionary<string, HandleSerial>();
|
||||
|
||||
@@ -37,18 +40,11 @@ namespace RH_Engine
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
|
||||
serialResponses.Add("route",handleRouteSerial);
|
||||
|
||||
TcpClient client = new TcpClient("145.48.6.10", 6666);
|
||||
|
||||
CreateConnection(client.GetStream());
|
||||
}
|
||||
|
||||
private static void handleRouteSerial(string uuid)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static void initReader(NetworkStream stream)
|
||||
{
|
||||
serverResponseReader = new ServerResponseReader(stream);
|
||||
@@ -78,14 +74,22 @@ namespace RH_Engine
|
||||
|
||||
if (message.Contains("serial"))
|
||||
{
|
||||
//Console.WriteLine("GOT MESSAGE WITH SERIAL: " + message + "\n\n\n");
|
||||
string serial = JSONParser.GetSerial(message);
|
||||
Console.WriteLine("Got serial " + serial);
|
||||
serialResponses[serial].Invoke();
|
||||
//Console.WriteLine("Got serial " + serial);
|
||||
if (serialResponses.ContainsKey(serial)) serialResponses[serial].Invoke(message);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void SendMessageAndOnResponse(NetworkStream stream, string message, string serial, HandleSerial action)
|
||||
{
|
||||
serialResponses.Add(serial,action);
|
||||
WriteTextMessage(stream, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// writes a message to the server
|
||||
/// </summary>
|
||||
@@ -140,16 +144,14 @@ namespace RH_Engine
|
||||
|
||||
|
||||
WriteTextMessage(stream, mainCommand.ResetScene());
|
||||
string routeid = CreateRoute(stream, mainCommand);
|
||||
SendMessageAndOnResponse(stream, mainCommand.RouteCommand("routeID"), "routeID", (message) => routeId = JSONParser.GetResponseUuid(message));
|
||||
|
||||
//WriteTextMessage(stream, mainCommand.TerrainCommand(new int[] { 256, 256 }, null));
|
||||
//string command;
|
||||
|
||||
//WriteTextMessage(stream, mainCommand.AddBikeModel());
|
||||
|
||||
|
||||
//command = mainCommand.AddBikeModel();
|
||||
|
||||
//WriteTextMessage(stream, command);
|
||||
SendMessageAndOnResponse(stream, mainCommand.addPanel("panelID"), "panelID", (message) => panelId = JSONParser.GetResponseUuid(message));
|
||||
|
||||
//Console.WriteLine(ReadPrefMessage(stream));
|
||||
|
||||
@@ -160,17 +162,21 @@ namespace RH_Engine
|
||||
//Console.WriteLine(ReadPrefMessage(stream));
|
||||
|
||||
|
||||
//command = mainCommand.addPanel();
|
||||
//WriteTextMessage(stream, command);
|
||||
//string response = ReadPrefMessage(stream);
|
||||
//Console.WriteLine("add Panel response: \n\r" + response);
|
||||
//string uuidPanel = JSONParser.getPanelID(response);
|
||||
//WriteTextMessage(stream, mainCommand.ClearPanel(uuidPanel));
|
||||
//Console.WriteLine(ReadPrefMessage(stream));
|
||||
//WriteTextMessage(stream, mainCommand.bikeSpeed(uuidPanel));
|
||||
//Console.WriteLine(ReadPrefMessage(stream));
|
||||
|
||||
//WriteTextMessage(stream, mainCommand.SwapPanelCommand(uuidPanel));
|
||||
//command = mainCommand.addPanel();
|
||||
// WriteTextMessage(stream, command);
|
||||
// string response = ReadPrefMessage(stream);
|
||||
// Console.WriteLine("add Panel response: \n\r" + response);
|
||||
// string uuidPanel = JSONParser.getPanelID(response);
|
||||
// WriteTextMessage(stream, mainCommand.ClearPanel(uuidPanel));
|
||||
// Console.WriteLine(ReadPrefMessage(stream));
|
||||
// WriteTextMessage(stream, mainCommand.bikeSpeed(uuidPanel, 2.42));
|
||||
// Console.WriteLine(ReadPrefMessage(stream));
|
||||
// WriteTextMessage(stream, mainCommand.ColorPanel(uuidPanel));
|
||||
// Console.WriteLine("Color panel: " + ReadPrefMessage(stream));
|
||||
// WriteTextMessage(stream, mainCommand.SwapPanel(uuidPanel));
|
||||
// Console.WriteLine("Swap panel: " + ReadPrefMessage(stream));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -196,20 +202,6 @@ namespace RH_Engine
|
||||
|
||||
}
|
||||
|
||||
public static string CreateRoute(NetworkStream stream, Command createGraphics)
|
||||
{
|
||||
//=============================================================================================================TODO change
|
||||
WriteTextMessage(stream, createGraphics.RouteCommand());
|
||||
//dynamic response = JsonConvert.DeserializeObject(ReadPrefMessage(stream));
|
||||
//dynamic response = null;
|
||||
//if (response.data.data.id == "route/add")
|
||||
//{
|
||||
// return response.data.data.data.uuid;
|
||||
//}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static void CreateTerrain(NetworkStream stream, Command createGraphics)
|
||||
{
|
||||
float x = 0f;
|
||||
|
||||
Reference in New Issue
Block a user