added stuff for connecting to vr engine
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace RH_Engine
|
namespace RH_Engine
|
||||||
{
|
{
|
||||||
@@ -6,7 +9,38 @@ namespace RH_Engine
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Hello World!");
|
|
||||||
|
// 0x1B,0x00,0x00,0x00
|
||||||
|
TcpClient client = new TcpClient("145.48.6.10", 6666);
|
||||||
|
|
||||||
|
WriteTextMessage(client, "{\"id\":\"session/list\"}");
|
||||||
|
Console.WriteLine("got response " + ReadTextMessage(client));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void WriteTextMessage(TcpClient client, string message)
|
||||||
|
{
|
||||||
|
byte[] msg = Encoding.ASCII.GetBytes(message);
|
||||||
|
byte[] res = new byte[msg.Length + 4];
|
||||||
|
res[0] = 0x1B;
|
||||||
|
for (int i = 1; i <= 3; i++)
|
||||||
|
{
|
||||||
|
res[i] = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
Array.Copy(res, 4, msg, 0, msg.Length);
|
||||||
|
var stream = new StreamWriter(client.GetStream(), Encoding.Default);
|
||||||
|
stream.Write(res);
|
||||||
|
stream.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ReadTextMessage(TcpClient client)
|
||||||
|
{
|
||||||
|
var stream = new StreamReader(client.GetStream(), Encoding.ASCII);
|
||||||
|
{
|
||||||
|
return stream.ReadLine();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,4 +6,8 @@
|
|||||||
<RootNamespace>RH_Engine</RootNamespace>
|
<RootNamespace>RH_Engine</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user