Esempio n. 1
0
        public Form_server()
        {
            InitializeComponent();

            try
            {
                var server_ip   = ConfigurationManager.AppSettings["server_ip"].ToString();
                var server_port = ConfigurationManager.AppSettings["server_port"].ToString();

                textBox_ip.Text   = server_ip;
                textBox_port.Text = server_port;

                IPEndPoint ep = new IPEndPoint(IPAddress.Parse(server_ip),
                                               int.Parse(server_port));

                _server = new ServerSide(ep,
                                         int.Parse(textBox_maxClients.Text),
                                         int.Parse(textBox_maxReq.Text),
                                         int.Parse(textBox_blockTime.Text));

                SetBindings();

                //добавим тестового пользователя
                _server.UsersBase.Add(new KeyValuePair <string, string>("yv", "0000"));
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Критическая ошибка! [{ex.Message}]");
                _server?.StopServer();
                this.Close();
            }

            this.FormClosed += Form_server_FormClosed;
        }
Esempio n. 2
0
        private void button_listen_Click(object sender, EventArgs e)
        {
            try
            {
                _server.Log += "Read rates...";
                _server.LoadRates("rates.txt");

                Task.Run(new Action(() =>
                {
                    _server.StartListen();
                }));
            }
            catch (Exception ex)
            {
                _server.Log += ex.Message;
                _server.Log += "Server is stoped!";
                _server.StopServer();
            }
        }
Esempio n. 3
0
 private void Form_server_FormClosed(object sender, FormClosedEventArgs e)
 {
     _server?.StopServer();
 }