OPENREC 7

This commit is contained in:
recroom2016tutorial
2022-07-21 23:49:29 -04:00
parent 696feb3887
commit 869f5ff80b
5 changed files with 68 additions and 44 deletions

View File

@@ -19,7 +19,8 @@ namespace server
{
Console.WriteLine("[NameServer.cs] has started.");
new Thread(new ThreadStart(this.StartListen)).Start();
}
new Thread(new ThreadStart(this.StartListen2)).Start();
}
catch (Exception ex)
{
Console.WriteLine("An Exception Occurred while Listening :" + ex.ToString());
@@ -31,33 +32,64 @@ namespace server
{
//nameserver is ONLY for 2018
this.listener.Prefixes.Add("http://localhost:20181/");
for (; ; )
{
this.listener.Start();
Console.WriteLine("[NameServer.cs] is listening.");
HttpListenerContext context = this.listener.GetContext();
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
string rawUrl = request.RawUrl;
string s = "";
NSData data = new NSData()
{
API = "http://localhost:2018",
Notifications = "http://localhost:20161",
Images = "http://localhost:20182"
};
s = JsonConvert.SerializeObject(data);
Console.WriteLine("API Response: " + s);
byte[] bytes = Encoding.UTF8.GetBytes(s);
response.ContentLength64 = (long)bytes.Length;
Stream outputStream = response.OutputStream;
outputStream.Write(bytes, 0, bytes.Length);
Thread.Sleep(1);
outputStream.Close();
this.listener.Stop();
}
}
public static string VersionCheckResponse = "{\"ValidVersion\":true}";
for (; ; )
{
this.listener.Start();
Console.WriteLine("[NameServer.cs] is listening.");
HttpListenerContext context = this.listener.GetContext();
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
string rawUrl = request.RawUrl;
string s = "";
NSData data = new NSData()
{
API = "http://localhost:2018",
Notifications = "http://localhost:20161",
Images = "http://localhost:20182"
};
s = JsonConvert.SerializeObject(data);
Console.WriteLine("API Response: " + s);
byte[] bytes = Encoding.UTF8.GetBytes(s);
response.ContentLength64 = (long)bytes.Length;
Stream outputStream = response.OutputStream;
outputStream.Write(bytes, 0, bytes.Length);
Thread.Sleep(400);
outputStream.Close();
this.listener.Stop();
}
}
private void StartListen2()
{
//nameserver is ONLY for 2018
this.listener2.Prefixes.Add("http://localhost:56/");
for (; ; )
{
this.listener2.Start();
Console.WriteLine("[NameServer2.cs] is listening.");
HttpListenerContext context = this.listener2.GetContext();
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
string rawUrl = request.RawUrl;
string s = "";
NSData data = new NSData()
{
API = "http://localhost:2018",
Notifications = "http://localhost:20161",
Images = "http://localhost:20182"
};
s = JsonConvert.SerializeObject(data);
Console.WriteLine("API Response: " + s);
byte[] bytes = Encoding.UTF8.GetBytes(s);
response.ContentLength64 = (long)bytes.Length;
Stream outputStream = response.OutputStream;
outputStream.Write(bytes, 0, bytes.Length);
Thread.Sleep(500);
outputStream.Close();
this.listener2.Stop();
}
}
public static string VersionCheckResponse = "{\"ValidVersion\":true}";
public static string BlankResponse = "";
public class NSData
{
@@ -69,5 +101,7 @@ namespace server
// Token: 0x04000192 RID: 402
private HttpListener listener = new HttpListener();
private HttpListener listener2 = new HttpListener();
}
}