Esempio n. 1
0
        static void Main(string[] args)
        {
            MainArgs arg = MainArgs.ValueOf(args);

            client = new DtuClient(
                arg.Get(MainArgs.KEY_SERVER_IP, "127.0.0.1"),
                arg.GetInt(MainArgs.KEY_SERVER_PORT, 5055)
                );
            client.OnReceived += OnMsg;
            client.Connect(20120049, "18651895100", "218.3.150.108");
            Thread t = new Thread(DoWork);

            t.Start();
            t.Join();
        }
Esempio n. 2
0
        public static MainArgs ValueOf(string[] args)
        {
            Dictionary <string, string> values = new Dictionary <string, string>();

            values[KEY_SERVER_IP]   = ConfigurationManager.AppSettings[KEY_SERVER_IP];
            values[KEY_SERVER_PORT] = ConfigurationManager.AppSettings[KEY_SERVER_PORT];
            if (args != null && args.Count() > 0)
            {
                foreach (string s in args)
                {
                    string[] ss = s.Split('=');
                    if (ss.Length == 2)
                    {
                        string key   = ss[0].Trim();
                        string value = ss[1].Trim();
                        values[key] = value;
                    }
                }
            }
            MainArgs a = new MainArgs();

            a.values = values;
            return(a);
        }