public static void Start(int maxPlayers) { MaxPlayers = maxPlayers; Console.WriteLine("Starting server..."); ReceiveManager = new ServerReceiveManager(); Send = new ServerSend(); tcpListener = new TcpListener(IPAddress.Any, Constants.PortTCP); tcpListener.Start(); tcpListener.BeginAcceptTcpClient(TCPConnectCallback, null); Console.WriteLine($"TCP Listener has Started (Port: {Constants.PortTCP})"); Action <Packet> serverUSPReceiveAction = (packet) => { ForwardUDPReceiveToClient(packet); }; udpReceiver = new UDPReceive(serverUSPReceiveAction); udpReceiver.StartListening(Constants.ServerPortUDP); Thread mainThread = new Thread(new ThreadStart(MainThread)); isRunning = true; mainThread.Start(); Console.WriteLine($"Server has started."); }
public void Connect(string ip, int tpcPort, int udpReceivePort, int udpSendPort) { isConnected = true; tcp.Connect(ip, tpcPort); if (Constants.AllowUDP) { udpReceive.StartListening(udpReceivePort); udpSend.Connect(ip, udpSendPort); } }