probably fixed the serials
This commit is contained in:
@@ -13,9 +13,9 @@ namespace ProftaakRH
|
|||||||
{
|
{
|
||||||
IDataReceiver dataReceiver = new DataConverter();
|
IDataReceiver dataReceiver = new DataConverter();
|
||||||
BLEHandler bLEHandler = new BLEHandler(dataReceiver);
|
BLEHandler bLEHandler = new BLEHandler(dataReceiver);
|
||||||
//BikeSimulator bikeSimulator = new BikeSimulator(dataConverter);
|
BikeSimulator bikeSimulator = new BikeSimulator(dataReceiver);
|
||||||
//bikeSimulator.setResistance(bikeSimulator.GenerateResistance(1f));
|
bikeSimulator.setResistance(bikeSimulator.GenerateResistance(1f));
|
||||||
//bikeSimulator.StartSimulation();
|
bikeSimulator.StartSimulation();
|
||||||
|
|
||||||
|
|
||||||
bool running = true;
|
bool running = true;
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ namespace RH_Engine
|
|||||||
dynamic payload = new
|
dynamic payload = new
|
||||||
{
|
{
|
||||||
id = "scene/node/add",
|
id = "scene/node/add",
|
||||||
|
serial = "needResponse",
|
||||||
data = new
|
data = new
|
||||||
{
|
{
|
||||||
name = "newNode",
|
name = "newNode",
|
||||||
@@ -106,11 +107,12 @@ namespace RH_Engine
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string addPanel()
|
public string addPanel(string serialToSend)
|
||||||
{
|
{
|
||||||
dynamic payload = new
|
dynamic payload = new
|
||||||
{
|
{
|
||||||
id = "scene/node/add",
|
id = "scene/node/add",
|
||||||
|
serial = serialToSend,
|
||||||
data = new
|
data = new
|
||||||
{
|
{
|
||||||
name = "dashboard",
|
name = "dashboard",
|
||||||
@@ -131,7 +133,36 @@ namespace RH_Engine
|
|||||||
return JsonConvert.SerializeObject(Payload(payload));
|
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
|
dynamic payload = new
|
||||||
{
|
{
|
||||||
@@ -140,7 +171,7 @@ namespace RH_Engine
|
|||||||
{
|
{
|
||||||
id = uuidPanel,
|
id = uuidPanel,
|
||||||
text = "Bike speed placeholder",
|
text = "Bike speed placeholder",
|
||||||
position = new int[] { 100, 100 },
|
position = new int[] { 0, 0 },
|
||||||
size = 32.0,
|
size = 32.0,
|
||||||
color = new int[] { 0, 0, 0, 1 },
|
color = new int[] { 0, 0, 0, 1 },
|
||||||
font = "segoeui"
|
font = "segoeui"
|
||||||
@@ -180,20 +211,20 @@ namespace RH_Engine
|
|||||||
|
|
||||||
public string AddBikeModel()
|
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;
|
string namename = nodeName;
|
||||||
bool animatedBool = false;
|
bool animatedBool = false;
|
||||||
@@ -205,6 +236,7 @@ namespace RH_Engine
|
|||||||
dynamic payload = new
|
dynamic payload = new
|
||||||
{
|
{
|
||||||
id = "scene/node/add",
|
id = "scene/node/add",
|
||||||
|
serial = serialToSend,
|
||||||
data = new
|
data = new
|
||||||
{
|
{
|
||||||
name = namename,
|
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);
|
ImprovedPerlin improvedPerlin = new ImprovedPerlin(4325, LibNoise.NoiseQuality.Best);
|
||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
dynamic payload = new
|
dynamic payload = new
|
||||||
{
|
{
|
||||||
id = "route/add",
|
id = "route/add",
|
||||||
serial = "route",
|
serial = serialToSend,
|
||||||
data = new
|
data = new
|
||||||
{
|
{
|
||||||
nodes = new dynamic[]
|
nodes = new dynamic[]
|
||||||
|
|||||||
@@ -81,9 +81,9 @@ namespace RH_Engine
|
|||||||
public static string GetResponseUuid(string json)
|
public static string GetResponseUuid(string json)
|
||||||
{
|
{
|
||||||
dynamic jsonData = JsonConvert.DeserializeObject(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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.Globalization;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Runtime.Intrinsics.X86;
|
using System.Runtime.Intrinsics.X86;
|
||||||
|
using System.Security.Cryptography;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -14,7 +15,7 @@ using System.Threading;
|
|||||||
namespace RH_Engine
|
namespace RH_Engine
|
||||||
{
|
{
|
||||||
|
|
||||||
public delegate void HandleSerial(string uuid);
|
public delegate void HandleSerial(string message);
|
||||||
internal class Program
|
internal class Program
|
||||||
{
|
{
|
||||||
private static PC[] PCs = {
|
private static PC[] PCs = {
|
||||||
@@ -30,6 +31,8 @@ namespace RH_Engine
|
|||||||
private static ServerResponseReader serverResponseReader;
|
private static ServerResponseReader serverResponseReader;
|
||||||
private static string sessionId = string.Empty;
|
private static string sessionId = string.Empty;
|
||||||
private static string tunnelId = 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>();
|
private static Dictionary<string, HandleSerial> serialResponses = new Dictionary<string, HandleSerial>();
|
||||||
|
|
||||||
@@ -37,18 +40,11 @@ namespace RH_Engine
|
|||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
serialResponses.Add("route",handleRouteSerial);
|
|
||||||
|
|
||||||
TcpClient client = new TcpClient("145.48.6.10", 6666);
|
TcpClient client = new TcpClient("145.48.6.10", 6666);
|
||||||
|
|
||||||
CreateConnection(client.GetStream());
|
CreateConnection(client.GetStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleRouteSerial(string uuid)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void initReader(NetworkStream stream)
|
private static void initReader(NetworkStream stream)
|
||||||
{
|
{
|
||||||
serverResponseReader = new ServerResponseReader(stream);
|
serverResponseReader = new ServerResponseReader(stream);
|
||||||
@@ -78,14 +74,22 @@ namespace RH_Engine
|
|||||||
|
|
||||||
if (message.Contains("serial"))
|
if (message.Contains("serial"))
|
||||||
{
|
{
|
||||||
|
//Console.WriteLine("GOT MESSAGE WITH SERIAL: " + message + "\n\n\n");
|
||||||
string serial = JSONParser.GetSerial(message);
|
string serial = JSONParser.GetSerial(message);
|
||||||
Console.WriteLine("Got serial " + serial);
|
//Console.WriteLine("Got serial " + serial);
|
||||||
serialResponses[serial].Invoke();
|
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>
|
/// <summary>
|
||||||
/// writes a message to the server
|
/// writes a message to the server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -140,16 +144,14 @@ namespace RH_Engine
|
|||||||
|
|
||||||
|
|
||||||
WriteTextMessage(stream, mainCommand.ResetScene());
|
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));
|
//WriteTextMessage(stream, mainCommand.TerrainCommand(new int[] { 256, 256 }, null));
|
||||||
//string command;
|
//string command;
|
||||||
|
|
||||||
|
//WriteTextMessage(stream, mainCommand.AddBikeModel());
|
||||||
|
|
||||||
|
SendMessageAndOnResponse(stream, mainCommand.addPanel("panelID"), "panelID", (message) => panelId = JSONParser.GetResponseUuid(message));
|
||||||
//command = mainCommand.AddBikeModel();
|
|
||||||
|
|
||||||
//WriteTextMessage(stream, command);
|
|
||||||
|
|
||||||
//Console.WriteLine(ReadPrefMessage(stream));
|
//Console.WriteLine(ReadPrefMessage(stream));
|
||||||
|
|
||||||
@@ -160,6 +162,7 @@ namespace RH_Engine
|
|||||||
//Console.WriteLine(ReadPrefMessage(stream));
|
//Console.WriteLine(ReadPrefMessage(stream));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//command = mainCommand.addPanel();
|
//command = mainCommand.addPanel();
|
||||||
// WriteTextMessage(stream, command);
|
// WriteTextMessage(stream, command);
|
||||||
// string response = ReadPrefMessage(stream);
|
// string response = ReadPrefMessage(stream);
|
||||||
@@ -167,10 +170,13 @@ namespace RH_Engine
|
|||||||
// string uuidPanel = JSONParser.getPanelID(response);
|
// string uuidPanel = JSONParser.getPanelID(response);
|
||||||
// WriteTextMessage(stream, mainCommand.ClearPanel(uuidPanel));
|
// WriteTextMessage(stream, mainCommand.ClearPanel(uuidPanel));
|
||||||
// Console.WriteLine(ReadPrefMessage(stream));
|
// Console.WriteLine(ReadPrefMessage(stream));
|
||||||
//WriteTextMessage(stream, mainCommand.bikeSpeed(uuidPanel));
|
// WriteTextMessage(stream, mainCommand.bikeSpeed(uuidPanel, 2.42));
|
||||||
// Console.WriteLine(ReadPrefMessage(stream));
|
// 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));
|
||||||
|
|
||||||
//WriteTextMessage(stream, mainCommand.SwapPanelCommand(uuidPanel));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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)
|
public static void CreateTerrain(NetworkStream stream, Command createGraphics)
|
||||||
{
|
{
|
||||||
float x = 0f;
|
float x = 0f;
|
||||||
|
|||||||
Reference in New Issue
Block a user