Exemple #1
0
        private void ConnectToServer()
        {
            ClientAuct.UserName = Login.Text;
            ClientAuct.Client   = new TcpClient();
            try
            {
                ClientAuct.Client.Connect(ClientAuct.Host, ClientAuct.Port); //подключение клиента
                ClientAuct.Stream = ClientAuct.Client.GetStream();           // получаем поток

                string message = ClientAuct.UserName;
                byte[] data    = Encoding.Unicode.GetBytes(message);
                ClientAuct.Stream.Write(data, 0, data.Length);

                // запускаем новый поток для получения данных
                Thread receiveThread = new Thread(new ThreadStart(ClientAuct.ReceiveMessage));
                receiveThread.Start(); //старт потока
                ClientAuct.SendMessage(Login.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
            //finally
            //{
            //    ClientAuct.Disconnect();
            //}
        }
Exemple #2
0
        private async void SetProductList()
        {
            Request request    = new Request("GetNewProductList");
            string  stringResp = await SendRequest(request);

            ProductList.ItemsSource = ClientAuct.DeserializeFromString <List <Product> >(stringResp);
            response = null;
            ProductList.DisplayMemberPath = "Name";
        }