示例#1
0
        public void NotifyOccured(NotifyType notifyType, Socket socket, BaseInfo baseInfo)
        {
            switch (notifyType)
            {
            case NotifyType.Notify_Socket:
            {
                QQMessageBox.Show(_ProgressForm, "服务器连接失败", "消息", QQMessageBoxIcon.Warning, QQMessageBoxButtons.OK);
                Environment.Exit(0);
            }
            break;

            case NotifyType.Reply_Server:
            {
                _ServerInfo   = (ServerInfo)baseInfo;
                _DownloadPath = _UpdateIni.GetIniValue("DownloadServer", "URL") + "/" + _ServerInfo.DownloadAddress;

                if (_DownloadPath[_DownloadPath.Length - 1] != '/')
                {
                    _DownloadPath += '/';
                }

                string localRoot = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + "\\..\\");
                WebDownloader.localRoot = localRoot;

                WebDownloader.progressForm = _ProgressForm;
                WebDownloader.GetInstance().DownloadFile("server.version", DownloadVersionCompleted, _DownloadPath);
            }
            break;
            }
        }
示例#2
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);
        }