-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
34 lines (27 loc) · 1.14 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Net;
using System.Threading.Tasks;
namespace Microservices_MicroServer {
class Program {
static void Main(string[] args) {
if (!HttpListener.IsSupported) {
Console.WriteLine("Something went wrong.\nYour platform does not support the System.Net.HttpListener class.\nServer can't work.");
return;
}
HttpListener listener = new HttpListener();
listener.Prefixes.Add(Constants.PREFIX_GETJOB);
listener.Prefixes.Add(Constants.PREFIX_POSTJOB);
listener.Start();
Task.Factory.StartNew(ClientHandler.WakeUpStuckGETs);
#if MicroServer_DebugEdition
Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + " [INFO] Server started");
Console.WriteLine("[INFO] GET-JOB URL: " + Constants.PREFIX_GETJOB);
Console.WriteLine("[INFO] POST-JOB URL: " + Constants.PREFIX_POSTJOB);
#endif
while (true) {
HttpListenerContext context = listener.GetContext();
Task.Factory.StartNew(ClientHandler.HandleClient, context);
}
}
}
}