예제 #1
0
        public bool Init()
        {
            _UpdateIni = new IniFileEdit(AppDomain.CurrentDomain.BaseDirectory + "Update.ini");

            string loginServerIP   = _UpdateIni.GetIniValue("LoginServer", "IP");
            string loginServerPort = _UpdateIni.GetIniValue("LoginServer", "PORT");

            _LoginEngine = new Client(InvokeSocket);

            if (_LoginEngine.Connect(loginServerIP, loginServerPort, ProtocolType.Tcp) == false)
            {
                QQMessageBox.Show(_ProgressForm, "服务器连接失败", "消息", QQMessageBoxIcon.Warning, QQMessageBoxButtons.OK);
                Environment.Exit(0);
            }

            _LoginEngine.AttachHandler(NotifyOccured);

            ResultInfo resultInfo = new ResultInfo();

            _LoginEngine.Send(NotifyType.Request_Server, resultInfo);

            return(true);
        }
예제 #2
0
        public bool NeedDownload()
        {
            while (_ServerVersions.Count > 0)
            {
                DownloadFileInfo foundInfo = null;

                foreach (DownloadFileInfo localInfo in _LocalVersions)
                {
                    if (localInfo.FilePath == _ServerVersions[0].FilePath)
                    {
                        foundInfo = localInfo;
                        break;
                    }
                }

                if (foundInfo == null)
                {
                    return(true);
                }

                if (foundInfo.FileVersion < _ServerVersions[0].FileVersion)
                {
                    return(true);
                }

                _ServerVersions.RemoveAt(0);
            }

            VersionInfo.WriteInfoFile(WebDownloader.localRoot, _LocalVersions, true);

            string gameRoot = WebDownloader.localRoot + "Games\\";

            if (Directory.Exists(gameRoot) == true)
            {
                DirectoryInfo gameRootInfo = new DirectoryInfo(gameRoot);

                foreach (DirectoryInfo gameFolderInfo in gameRootInfo.GetDirectories())
                {
                    string engineName = WebDownloader.localRoot + "ChatEngine.dll";
                    File.Copy(engineName, gameFolderInfo.FullName + "\\ChatEngien.dll", true);

                    string controlName = WebDownloader.localRoot + "GameControls.dll";
                    File.Copy(controlName, gameFolderInfo.FullName + "\\GameControls.dll", true);
                }
            }

            IniFileEdit UserIni = new IniFileEdit(WebDownloader.localRoot + "UserInfo.ini");

            UserIni.SetIniValue("ServerInfo", "ServerUri", _UpdateIni.GetIniValue("LoginServer", "IP"));
            UserIni.SetIniValue("ServerInfo", "ServerPort", _ServerInfo.ServerPort.ToString());
            UserIni.SetIniValue("ServerInfo", "ServerGamePath", _DownloadPath);


            // Prepare the process to run
            ProcessStartInfo start = new ProcessStartInfo();

            // Enter in the command line arguments, everything you would enter after the executable name itself
            //start.Arguments = arguments;
            // Enter the executable to run, including the complete path
            start.FileName         = WebDownloader.localRoot + "ChatClient.exe";
            start.WorkingDirectory = WebDownloader.localRoot;
            // Do you want to show a console window?
            //start.WindowStyle = ProcessWindowStyle.Hidden;
            //start.CreateNoWindow = true;

            // Run the external process & wait for it to finish
            //using (Process proc = Process.Start(start))
            //{
            //    proc.WaitForExit();

            //    // Retrieve the app's exit code
            //    exitCode = proc.ExitCode;
            //}



            Process proc = Process.Start(start);

            //System.Diagnostics.Process.Start(WebDownloader.localRoot + "ChatClient.exe");
            Environment.Exit(0);

            return(false);
        }