예제 #1
0
파일: ZeusClient.cs 프로젝트: onixion/zeus
 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);
     }
 }
예제 #2
0
파일: ZeusClient.cs 프로젝트: onixion/zeus
 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"));
 }
예제 #3
0
파일: ZeusClient.cs 프로젝트: onixion/zeus
 public ZeusClient(ZeusClientConfig config)
 {
     _config = config;
 }
예제 #4
0
파일: Program.cs 프로젝트: onixion/zeus
        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();
        }