public static void Stop() { Development.Log("Stopping Server"); if (TcpReady) { Development.Log("Shutting Down TCP Listener"); tcpListener.Stop(); tcpListener = null; } if (UdpReady) { Development.Log("Shutting Down UDP Listener"); udpListener.Close(); udpListener = null; } if (PacketsReady) { Development.Log("Clearing Packet Receivers"); packetReceivers.Clear(); packetReceivers = null; } if (ClientsReady) { // Setup Max Clients Development.Log("Clearing Client Connections"); clients.Clear(); } if (DatabaseReady) { Game.Save(); Development.Log("Disconnected from MySQL"); database.Disconnect(); database = null; } Development.Log("Server Shutdown"); IsReady = false; Development.Divider(); }
public static void Start(int _maxPlayers, int _port) { Util.IniFile MyIni = new Util.IniFile("Settings.ini"); string section = "MySQL"; string host = MyIni.Read("Host", section); string user = MyIni.Read("Username", section); string pass = MyIni.Read("Password", section); string db = MyIni.Read("Database", section); database = new Database.Connection(host, db, user, pass, true); Development.Log("Starting Server"); MaxPlayers = _maxPlayers; Port = _port; // Setup Server Packets InitializeServerData(); Development.Divider(); }