Пример #1
0
 public Form1(String Login,Wiadomosci polaczenie)
 {
     InitializeComponent();
     mm = polaczenie;
     login = Login;
     backgroundWorker1.RunWorkerAsync();
 }
Пример #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            HttpChannel d = new HttpChannel();
            try
            {

                ChannelServices.RegisterChannel(d);

                mm = (Wiadomosci)Activator.GetObject(typeof(SimpleConection.Wiadomosci),
                    "http://" + textBox5.Text + ":" + (textBox9.Text.Length == 0 ? "3000" : textBox9.Text) + "/Polaczenie");
                login = textBox7.Text;
                string haslo = maskedTextBox2.Text;
                if (maskedTextBox2.Text == maskedTextBox3.Text)
                    if (mm.rejestracja(login, haslo))
                    {
                        zatw = true;
                        DialogResult = DialogResult.OK;
                        mm.logowanie(login, haslo);
                    }
                    else { MessageBox.Show("login juz istnije"); throw new Exception(); }
                else{ MessageBox.Show("zle hasla"); throw new Exception(); }
                //backgroundWorker1.RunWorkerAsync();
            }
            catch
            {
                //MessageBox.Show("błedny adres lub port serwera");
                ChannelServices.UnregisterChannel(d);
            }
        }
Пример #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            HttpChannel d = new HttpChannel();
            try
            {

                ChannelServices.RegisterChannel(d);

                mm = (Wiadomosci)Activator.GetObject(typeof(SimpleConection.Wiadomosci),
                    "http://" + textBox3.Text + ":" + (textBox8.Text.Length == 0 ? "3000" : textBox8.Text) + "/Polaczenie");
                login = textBox1.Text;
                string haslo = maskedTextBox1.Text;
                if (mm.logowanie(login, haslo))
                {
                    zatw = true;
                    DialogResult = DialogResult.OK;
                }
                else MessageBox.Show("błedny login lub haslo");
                //backgroundWorker1.RunWorkerAsync();
            }
            catch {
                MessageBox.Show("błedny adres lub port serwera");
                //ChannelServices.UnregisterChannel(d);
            }
        }
Пример #4
0
        private void button6_Click_1(object sender, EventArgs e)
        {
            tempChannel = new HttpChannel(textBox3.Text.Length == 0 ? 3000 : int.Parse(textBox3.Text));
            ChannelServices.RegisterChannel(tempChannel);

            Type ServerType = typeof(SimpleConection.Wiadomosci);
            RemotingConfiguration.RegisterWellKnownServiceType(ServerType,
                                "Polaczenie",
                                WellKnownObjectMode.Singleton);

            mm = (Wiadomosci)Activator.GetObject(typeof(SimpleConection.Wiadomosci),
                                                "http://localhost:" + (textBox3.Text.Length == 0 ? "3000" : textBox3.Text) + "/Polaczenie");

            abcd = new Thread(new ThreadStart(poszukuj));
            abcd.Start();
            _aktywni = new Thread(new ThreadStart(lista_aktywnych));
            _aktywni.Start();
            _odbieranie = new Thread(new ThreadStart(odbieranie));
            _odbieranie.Start();
            button7.Enabled = true;
            button6.Enabled = false;
        }
Пример #5
0
        private void button8_Click(object sender, EventArgs e)
        {
            //HttpChannel c = new HttpChannel(3000);
            // rozlaczenie polaczenia ubieglego
            if (tempChannel != null)
            {
                mm.rozlaczServer();
                backgroundWorker1.CancelAsync();
                backgroundWorker3.CancelAsync();
                ChannelServices.UnregisterChannel(tempChannel);
            }
            //RemotingConfiguration.
            //HttpChannel c = new HttpChannel(textBox3.Text.Length <= 0 ? 3000 : int.Parse(textBox3.Text));
            tempChannel = new HttpChannel(3000);
            ChannelServices.RegisterChannel(tempChannel);

            Type ServerType = typeof(SimpleConection.Wiadomosci);
            RemotingConfiguration.RegisterWellKnownServiceType(ServerType,
                                "Polaczenie",
                                WellKnownObjectMode.Singleton);
            //RemotingConfiguration.RegisterWellKnownClientType(ServerType, "http://localhost:3000/Polaczenie");

            //---------------------------------------------------------------------------------
            string myID = "Server";

            mm = (Wiadomosci)Activator.GetObject(typeof(SimpleConection.Wiadomosci),
                                                "http://localhost:3000/Polaczenie");
            //HttpChannel d = new HttpChannel();
            //ChannelServices.RegisterChannel(d);
            // (2) Rejestruje typ — obiekt aktywowany przez serwer przez port 3200

            // (3) Tworzy instancję zdalnego obiektu
               // mm = new Wiadomosci();

            // Pozwala użytkownikom wysyłać i odbierać wiadomości

            backgroundWorker1.RunWorkerAsync();
            abcd = new Thread(new ThreadStart(poszukuj));
            abcd.Start();
            //backgroundWorker2.RunWorkerAsync();
            backgroundWorker3.RunWorkerAsync();
        }
Пример #6
0
        private void button6_Click(object sender, EventArgs e)
        {
            HttpChannel d = new HttpChannel();
            ChannelServices.RegisterChannel(d);

            mm = (Wiadomosci)Activator.GetObject(typeof(SimpleConection.Wiadomosci),
                                                "http://"+textBox2.Text+":3000/Polaczenie");
            login = textBox5.Text;

            mm.logowanie(login, "lala");
            backgroundWorker1.RunWorkerAsync();
        }