cleanup files
This commit is contained in:
@@ -1,14 +1,10 @@
|
|||||||
using LibNoise.Primitive;
|
using LibNoise.Primitive;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace RH_Engine
|
namespace RH_Engine
|
||||||
{
|
{
|
||||||
class Command
|
internal class Command
|
||||||
{
|
{
|
||||||
public const string STANDARD_HEAD = "Head";
|
public const string STANDARD_HEAD = "Head";
|
||||||
public const string STANDARD_GROUND = "GroundPlane";
|
public const string STANDARD_GROUND = "GroundPlane";
|
||||||
@@ -16,9 +12,7 @@ namespace RH_Engine
|
|||||||
public const string STANDARD_LEFTHAND = "LeftHand";
|
public const string STANDARD_LEFTHAND = "LeftHand";
|
||||||
public const string STANDARD_RIGHTHAND = "RightHand";
|
public const string STANDARD_RIGHTHAND = "RightHand";
|
||||||
|
|
||||||
|
private string tunnelID;
|
||||||
|
|
||||||
string tunnelID;
|
|
||||||
|
|
||||||
public Command(string tunnelID)
|
public Command(string tunnelID)
|
||||||
{
|
{
|
||||||
@@ -35,10 +29,10 @@ namespace RH_Engine
|
|||||||
size = sizeArray,
|
size = sizeArray,
|
||||||
heights = heightsArray
|
heights = heightsArray
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
return JsonConvert.SerializeObject(Payload(payload));
|
return JsonConvert.SerializeObject(Payload(payload));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AddLayer(string uid, string texture)
|
public string AddLayer(string uid, string texture)
|
||||||
{
|
{
|
||||||
dynamic payload = new
|
dynamic payload = new
|
||||||
@@ -56,6 +50,7 @@ namespace RH_Engine
|
|||||||
};
|
};
|
||||||
return JsonConvert.SerializeObject(Payload(payload));
|
return JsonConvert.SerializeObject(Payload(payload));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string UpdateTerrain()
|
public string UpdateTerrain()
|
||||||
{
|
{
|
||||||
dynamic payload = new
|
dynamic payload = new
|
||||||
@@ -63,7 +58,6 @@ namespace RH_Engine
|
|||||||
id = "scene/terrain/update",
|
id = "scene/terrain/update",
|
||||||
data = new
|
data = new
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return JsonConvert.SerializeObject(Payload(payload));
|
return JsonConvert.SerializeObject(Payload(payload));
|
||||||
@@ -91,19 +85,15 @@ namespace RH_Engine
|
|||||||
|
|
||||||
public string DeleteNode(string uuid)
|
public string DeleteNode(string uuid)
|
||||||
{
|
{
|
||||||
|
|
||||||
dynamic payload = new
|
dynamic payload = new
|
||||||
{
|
{
|
||||||
id = "scene/node/delete",
|
id = "scene/node/delete",
|
||||||
data = new
|
data = new
|
||||||
{
|
{
|
||||||
id = uuid,
|
id = uuid,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
return JsonConvert.SerializeObject(Payload(payload));
|
return JsonConvert.SerializeObject(Payload(payload));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string addPanel(string serialToSend)
|
public string addPanel(string serialToSend)
|
||||||
@@ -123,7 +113,6 @@ namespace RH_Engine
|
|||||||
resolution = new int[] { 512, 512 },
|
resolution = new int[] { 512, 512 },
|
||||||
background = new int[] { 1, 0, 0, 0 },
|
background = new int[] { 1, 0, 0, 0 },
|
||||||
castShadow = false
|
castShadow = false
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,7 +235,6 @@ namespace RH_Engine
|
|||||||
position = positionVector,
|
position = positionVector,
|
||||||
scale = scalar,
|
scale = scalar,
|
||||||
rotation = rotationVector
|
rotation = rotationVector
|
||||||
|
|
||||||
},
|
},
|
||||||
model = new
|
model = new
|
||||||
{
|
{
|
||||||
@@ -257,7 +245,6 @@ namespace RH_Engine
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
return JsonConvert.SerializeObject(Payload(payload));
|
return JsonConvert.SerializeObject(Payload(payload));
|
||||||
}
|
}
|
||||||
@@ -287,7 +274,6 @@ namespace RH_Engine
|
|||||||
return JsonConvert.SerializeObject(Payload(payload));
|
return JsonConvert.SerializeObject(Payload(payload));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public string RouteCommand(string serialToSend)
|
public string RouteCommand(string serialToSend)
|
||||||
{
|
{
|
||||||
ImprovedPerlin improvedPerlin = new ImprovedPerlin(4325, LibNoise.NoiseQuality.Best);
|
ImprovedPerlin improvedPerlin = new ImprovedPerlin(4325, LibNoise.NoiseQuality.Best);
|
||||||
@@ -401,7 +387,6 @@ namespace RH_Engine
|
|||||||
throw new Exception("The time must be between 0 and 24!");
|
throw new Exception("The time must be between 0 and 24!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dynamic payload = new
|
dynamic payload = new
|
||||||
{
|
{
|
||||||
id = "scene/skybox/settime",
|
id = "scene/skybox/settime",
|
||||||
@@ -409,13 +394,10 @@ namespace RH_Engine
|
|||||||
{
|
{
|
||||||
time = timeToSet
|
time = timeToSet
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
return JsonConvert.SerializeObject(Payload(payload));
|
return JsonConvert.SerializeObject(Payload(payload));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private object Payload(dynamic message)
|
private object Payload(dynamic message)
|
||||||
{
|
{
|
||||||
return new
|
return new
|
||||||
@@ -428,8 +410,5 @@ namespace RH_Engine
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
using System;
|
using Newtonsoft.Json;
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Text;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace RH_Engine
|
namespace RH_Engine
|
||||||
{
|
{
|
||||||
@@ -27,7 +23,6 @@ namespace RH_Engine
|
|||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetSessionID(string msg, PC[] PCs)
|
public static string GetSessionID(string msg, PC[] PCs)
|
||||||
@@ -60,7 +55,6 @@ namespace RH_Engine
|
|||||||
{
|
{
|
||||||
dynamic d = JsonConvert.DeserializeObject(json);
|
dynamic d = JsonConvert.DeserializeObject(json);
|
||||||
return d.id;
|
return d.id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetTunnelID(string json)
|
public static string GetTunnelID(string json)
|
||||||
|
|||||||
@@ -3,19 +3,13 @@ using Newtonsoft.Json;
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
|
||||||
using System.IO;
|
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Runtime.Intrinsics.X86;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace RH_Engine
|
namespace RH_Engine
|
||||||
{
|
{
|
||||||
|
|
||||||
public delegate void HandleSerial(string message);
|
public delegate void HandleSerial(string message);
|
||||||
|
|
||||||
internal class Program
|
internal class Program
|
||||||
{
|
{
|
||||||
private static PC[] PCs = {
|
private static PC[] PCs = {
|
||||||
@@ -36,10 +30,8 @@ namespace RH_Engine
|
|||||||
|
|
||||||
private static Dictionary<string, HandleSerial> serialResponses = new Dictionary<string, HandleSerial>();
|
private static Dictionary<string, HandleSerial> serialResponses = new Dictionary<string, HandleSerial>();
|
||||||
|
|
||||||
|
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
TcpClient client = new TcpClient("145.48.6.10", 6666);
|
TcpClient client = new TcpClient("145.48.6.10", 6666);
|
||||||
|
|
||||||
CreateConnection(client.GetStream());
|
CreateConnection(client.GetStream());
|
||||||
@@ -62,14 +54,14 @@ namespace RH_Engine
|
|||||||
/// <param name="message">the response message from the server</param>
|
/// <param name="message">the response message from the server</param>
|
||||||
public static void HandleResponse(string message)
|
public static void HandleResponse(string message)
|
||||||
{
|
{
|
||||||
|
|
||||||
string id = JSONParser.GetID(message);
|
string id = JSONParser.GetID(message);
|
||||||
|
|
||||||
// because the first messages don't have a serial, we need to check on the id
|
// because the first messages don't have a serial, we need to check on the id
|
||||||
if (id == "session/list")
|
if (id == "session/list")
|
||||||
{
|
{
|
||||||
sessionId = JSONParser.GetSessionID(message, PCs);
|
sessionId = JSONParser.GetSessionID(message, PCs);
|
||||||
} else if (id == "tunnel/create")
|
}
|
||||||
|
else if (id == "tunnel/create")
|
||||||
{
|
{
|
||||||
tunnelId = JSONParser.GetTunnelID(message);
|
tunnelId = JSONParser.GetTunnelID(message);
|
||||||
if (tunnelId == null)
|
if (tunnelId == null)
|
||||||
@@ -85,7 +77,6 @@ namespace RH_Engine
|
|||||||
string serial = JSONParser.GetSerial(message);
|
string serial = JSONParser.GetSerial(message);
|
||||||
//Console.WriteLine("Got serial " + serial);
|
//Console.WriteLine("Got serial " + serial);
|
||||||
if (serialResponses.ContainsKey(serial)) serialResponses[serial].Invoke(message);
|
if (serialResponses.ContainsKey(serial)) serialResponses[serial].Invoke(message);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,8 +111,6 @@ namespace RH_Engine
|
|||||||
Console.WriteLine("sent message " + message);
|
Console.WriteLine("sent message " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// connects to the server and creates the tunnel
|
/// connects to the server and creates the tunnel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -154,11 +143,9 @@ namespace RH_Engine
|
|||||||
{
|
{
|
||||||
Command mainCommand = new Command(tunnelID);
|
Command mainCommand = new Command(tunnelID);
|
||||||
|
|
||||||
|
|
||||||
WriteTextMessage(stream, mainCommand.ResetScene());
|
WriteTextMessage(stream, mainCommand.ResetScene());
|
||||||
SendMessageAndOnResponse(stream, mainCommand.RouteCommand("routeID"), "routeID", (message) => routeId = JSONParser.GetResponseUuid(message));
|
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;
|
||||||
|
|
||||||
@@ -182,7 +169,6 @@ namespace RH_Engine
|
|||||||
// Console.WriteLine("Color panel: " + ReadPrefMessage(stream));
|
// Console.WriteLine("Color panel: " + ReadPrefMessage(stream));
|
||||||
// WriteTextMessage(stream, mainCommand.SwapPanel(uuidPanel));
|
// WriteTextMessage(stream, mainCommand.SwapPanel(uuidPanel));
|
||||||
// Console.WriteLine("Swap panel: " + ReadPrefMessage(stream));
|
// Console.WriteLine("Swap panel: " + ReadPrefMessage(stream));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -205,7 +191,6 @@ namespace RH_Engine
|
|||||||
}
|
}
|
||||||
Console.WriteLine("Could not find id of " + name);
|
Console.WriteLine("Could not find id of " + name);
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CreateTerrain(NetworkStream stream, Command createGraphics)
|
public static void CreateTerrain(NetworkStream stream, Command createGraphics)
|
||||||
@@ -260,9 +245,7 @@ namespace RH_Engine
|
|||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -275,6 +258,7 @@ namespace RH_Engine
|
|||||||
this.host = host;
|
this.host = host;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string host { get; }
|
public string host { get; }
|
||||||
public string user { get; }
|
public string user { get; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -7,12 +6,14 @@ using System.Threading;
|
|||||||
namespace RH_Engine
|
namespace RH_Engine
|
||||||
{
|
{
|
||||||
public delegate void OnResponse(string response);
|
public delegate void OnResponse(string response);
|
||||||
|
|
||||||
class ServerResponseReader
|
class ServerResponseReader
|
||||||
{
|
{
|
||||||
public OnResponse callback
|
public OnResponse callback
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkStream Stream { get; }
|
public NetworkStream Stream { get; }
|
||||||
|
|
||||||
public ServerResponseReader(NetworkStream stream)
|
public ServerResponseReader(NetworkStream stream)
|
||||||
|
|||||||
Reference in New Issue
Block a user