/// <summary> /// Stop listening for incoming packets. /// </summary> public override void Stop() { if (mThread != null) { mThread.Interrupt(); mThread.Join(); mThread = null; } if (mUdp != null) { mUdp.Stop(); mUdp = null; Tools.LoadList(banFilePath, mBan); } mList.Clear(); }
/// <summary> /// Start listening for incoming UDP packets on the specified listener port. /// </summary> public override bool Start(int listenPort) { Stop(); Tools.LoadList(banFilePath, mBan); #if FORCE_EN_US Tools.SetCurrentCultureToEnUS(); #endif mUdp = new UdpProtocol("Lobby Server"); if (!mUdp.Start(listenPort, UdpProtocol.defaultBroadcastInterface)) { return(false); } #if STANDALONE Tools.Print("Bans: " + mBan.Count); Tools.Print("UDP Lobby Server started on port " + listenPort + " using interface " + UdpProtocol.defaultNetworkInterface); #endif mThread = Tools.CreateThread(ThreadFunction); mThread.Start(); return(true); }
/// <summary> /// Start listening for incoming connections. /// </summary> public override bool Start(int listenPort) { Stop(); Tools.LoadList(banFilePath, mBan); #if FORCE_EN_US Tools.SetCurrentCultureToEnUS(); #endif try { mListener = new TcpListener(TNet.TcpProtocol.defaultListenerInterface, listenPort); mListener.Start(50); mPort = listenPort; } #if STANDALONE catch (System.Exception ex) { Tools.LogError(ex.Message, ex.StackTrace); return(false); } Tools.Print("Bans: " + mBan.Count); Tools.Print("TCP Lobby Server started on port " + listenPort);
/// <summary> /// Load a previously saved ban list. /// </summary> public void LoadBanList() { Tools.Print("Bans: " + (Tools.LoadList(string.IsNullOrEmpty(rootDirectory) ? banFilePath : Path.Combine(rootDirectory, banFilePath), mBan) ? mBan.Count.ToString() : "file not found")); }