Esempio n. 1
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            string text;

            this.serverIp = new ServerIp(this.textAddress.Text, (int)this.numericPort.Value);

            if (this.serverIp.Address == null)
            {
                TitleError error = new TitleError();
                text = "Server adresa nije validna, pokusajte ponovo unijeti istu.";
                MessageBoxAdv.Show(text, error.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                serverIp = null;
                return;
            }

            ServerPing sp = new ServerPing(serverIp);

            if (sp.Ping() > 0)
            {
                this.userFile.ServerList.Insert(0, new UserServer(this.textAddress.Text, (int)this.numericPort.Value));
                this.userFile.Write();
                this.Close();
                return;
            }

            TitleWarning warn = new TitleWarning();

            text = "Server nije odgovorio na zahtjev, pokusajte ponovo potvrditi!";
            MessageBoxAdv.Show(text, warn.Caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
Esempio n. 2
0
        private void workerStatus_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            if (worker == null)
            {
                return;
            }

            if (worker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }

            if (e.Argument != null)
            {
                e.Result = serverInfo.Info() ? -1 : -2;
                return;
            }

            for (int i = 0; i < 20; i++)
            {
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                Thread.Sleep(500);
            }

            e.Result = serverPing.Ping();
        }
Esempio n. 3
0
        public bool IsLive()
        {
            ServerPing sp = new ServerPing(this);

            return(sp.Ping() > 0 ? true : false);
        }