This repository was archived by the owner on Jun 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (49 loc) · 1.38 KB
/
Program.cs
File metadata and controls
57 lines (49 loc) · 1.38 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Text;
using System.Threading;
using Microsoft.Extensions.Logging;
using Serilog;
using TheP0ngServer.Models;
using TheP0ngServer.ProtocolManagers;
namespace TheP0ngServer
{
public class Program
{
static void Main(string[] args)
{
int port = Configs.Port;
int gameServicePort = Configs.GameServicePort;
string schoolCode = Configs.SchoolCode;
string apiDomain = Configs.GameServiceIP;
LoggerService logger = new LoggerService();
logger.LogInformation($"Started Server on Port: {port}, Connecting to: {apiDomain}, where SchoolCode: {schoolCode}");
//Starts TCP on a new thread and a new thread for UDP and tcp branches have new threads for handling new clients;
try
{
Thread udpThread = new Thread(() => UdpListener.StartUdpListening(port, apiDomain, gameServicePort));
udpThread.Start();
}
catch (Exception exception)
{
logger.LogError($"Error with udpThread: {exception}");
}
try
{
Thread tcpThread = new Thread(() => TcpManager.StartTcpServer(port, apiDomain, schoolCode));
tcpThread.Start();
}
catch (Exception exception)
{
logger.LogError($"Error with tcpThread: {exception}");
}
finally
{
logger.CloseLogger();
}
}
}
}