public static void Save(string path, ZeusClientConfig config) { XmlSerializer _serializer = new XmlSerializer(typeof(ZeusClientConfig)); using (FileStream _stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None)) { _serializer.Serialize(_stream, config); } }
public static ZeusClientConfig Init(string path) { if (!File.Exists(Path.Combine(path, "zeus.conf"))) { ZeusClientConfig _config = new ZeusClientConfig(); _config.SetDefault(); Save(Path.Combine(path, "zeus.conf"), _config); } return Load(Path.Combine(path, "zeus.conf")); }
public ZeusClient(ZeusClientConfig config) { _config = config; }
public static void Main(string[] args) { ZeusClientConfig _config = new ZeusClientConfig(); _config = ZeusClient.Init("."); ZeusClient _client = new ZeusClient(_config); try { _client.Connect(); } catch (Exception) { Console.WriteLine("Could not connect to server (IP:" + _config.ip + " PORT:" + _config.port + ")."); Console.WriteLine("Press any key to continue ..."); Console.ReadKey(); return; } Console.WriteLine("Connected to server (IP:" + _config.ip + " PORT:" + _config.port + ")."); try { if (args.Length >= 1) { if (args[0] == "test") { while (true) { _client.OPTest(); System.Threading.Thread.Sleep(1000); } } else if (args[0] == "log") { _client.OPLog(args[1]); } else if (args[0] == "logget") { Console.WriteLine(_client.OPGetLog(Convert.ToInt32(args[1]))); } else if (args[0] == "info") { _client.OPInfo(); } else if (args[0] == "file") { using (FileStream _file = new FileStream(args[2], FileMode.Create, FileAccess.Write, FileShare.None)) { _client.OPDownloadFile(_file, args[1]); } } } _client.Disconnect(); } catch (Exception) { Console.WriteLine("Lost connection ..."); } Console.WriteLine("Press any key to continue ..."); Console.ReadKey(); }