Exemplo n.º 1
0
 void ConnectUser()
 {
     if (!isConnected)
     {
         client             = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
         ID                 = client.Connect(tbUserName.Text);
         tbUserName.Enabled = false;
         bConnDicon.Text    = "Disconnect";
         isConnected        = true;
         var str = Assembly.GetExecutingAssembly().Location;
         var ar  = str.Split('\\');
         str = "";
         for (int i = 0; i < ar.Length - 4; i++)
         {
             str += ar[i] + "/";
         }
         str += "/ChatHost/bin/Debug/history.txt";
         try
         {
             var lines = File.ReadAllLines(str, Encoding.UTF8);
             foreach (var line in lines)
             {
                 lbChat.Items.Add(line);
             }
             lbChat.SelectedIndex = lbChat.Items.Count - 1;
         }
         catch
         {
             MessageBox.Show("Нет файла истории ");
         }
     }
 }
Exemplo n.º 2
0
 void ConnectUser()
 {
     if (!isConnected)
     {
         client      = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
         ID          = client.Connect(label1.Text);
         isConnected = true;
     }
 }
Exemplo n.º 3
0
 void ConnectUser()  //робота кнопки і заміна контенту кнопки
 {
     if (!isConnected)
     {
         client = new ServiceChatClient(new System.ServiceModel.InstanceContext(this)); //на момент загруження вікна у нас буде створюватися обєкт
         ID     = client.Connect(tbUserName.Text);
         tbUserName.IsEnabled = false;                                                  //коли ввели імя ми неможемо його вже змінювати...
         bConnDicon.Content   = "Disconnect";
         isConnected          = true;
     }
 }
Exemplo n.º 4
0
 void ConnectUser()
 {
     if (!isConnected)
     {
         _client = new ServiceChatClient(new InstanceContext(this));
         ID      = _client.Connect(tbUserName.Text);
         tbUserName.IsEnabled = false;
         bConDiscon.Content   = "Disconnect";
         isConnected          = true;
     }
 }
Exemplo n.º 5
0
 void ConnectUser()
 {
     if (!isConnected)
     {
         client = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
         id     = client.Connect(tbUserName.Text);
         tbUserName.IsEnabled = false;
         btConnect.Content    = "Отключиться";
         isConnected          = true;
     }
 }
Exemplo n.º 6
0
 void ConnectUser()
 {
     if (!isConnected)
     {
         client = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
         userID = client.Connect(tbUserName.Text);
         tbUserName.IsEnabled       = false;
         bConnectDisconnect.Content = "Disconnect";
         isConnected = true;
     }
 }
Exemplo n.º 7
0
 void Connect()
 {
     if (!isConnected)
     {
         client        = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
         ID            = client.Connect(TB.Text);
         TB.IsEnabled  = false;
         TextBloc.Text = "Вихід";
         isConnected   = true;
     }
 }
Exemplo n.º 8
0
 void ConnectUser()      // Подключение к сервису
 {
     if (!isConnected)
     {
         client = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
         ID     = client.Connect(tbUserName.Text);
         tbUserName.IsEnabled = false;
         bConnDicon.Content   = "Disconnect";
         isConnected          = true;
     }
 }
Exemplo n.º 9
0
 //подключение к серверу
 void ConnectUser()
 {
     if (!isConnected)
     {
         client = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
         PrintUsers();
         Id = client.Connect(tblockUserName.Text);
         client.SendOnlineUsers(tbMessage.Text, Id);
         tblockUserName.Foreground = Brushes.Green;
         isConnected = true;
     }
 }
Exemplo n.º 10
0
 void ConnectUser()
 {
     if (!isConnected)
     {
         client = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
         ID     = client.Connect(tbUserName.Text);
         tbUserName.IsEnabled = false;
         bConDis.Content      = "Disconnect";
         bConDis.Background   = Brushes.Red;
         isConnected          = true;
     }
 }
Exemplo n.º 11
0
 void ConnectUser()
 {
     if (!isConnected)
     {
         client = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
         ID     = client.Connect(tbUserName.Text);
         tbUserName.IsEnabled = false;
         bConnDicon.Content   = "Disconnect";
         isConnected          = true;
         client.MassMessagig("IM ALIVE DETKA");
     }
 }
Exemplo n.º 12
0
 private void ConnectUser()
 {
     if (!_isConnected)
     {
         _chatClient  = new ServiceChatClient(new InstanceContext(this));
         _userId      = _chatClient.Connect(UserNameTextBox.Text);
         _isConnected = true;
         UserNameTextBox.IsEnabled         = false;
         MessageTextBox.IsEnabled          = true;
         ConnectOrDisconnectButton.Content = "Покинуть чат";
     }
 }
Exemplo n.º 13
0
 void ConnectUser()
 {
     if (!isConnected)
     {
         serpent              = new Serpent();
         KeyToSerpent         = Convert.ToBase64String(serpent.GenerateKey());
         client               = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
         ID                   = client.Connect(tbUserName.Text, KeyToSerpent);
         tbUserName.IsEnabled = false;
         bConnDicon.Content   = "Disconnect";
         isConnected          = true;
     }
 }
Exemplo n.º 14
0
 void Connect()
 {
     if (!isConnected)
     {
         client = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
         id     = client.Connect(tbUserName.Text);
         tbUserName.IsEnabled   = false;
         bConnDiscon.Content    = "Disconnect";
         tbStatusBar.Text       = "online";
         tbStatusBar.Foreground = (Brush)System.ComponentModel.TypeDescriptor.GetConverter(typeof(Brush)).ConvertFromInvariantString("Green");
         isConnected            = true;
     }
 }
Exemplo n.º 15
0
 void ConnectUser()
 {
     if (!isConnected)
     {
         client = new ServiceChatClient(new InstanceContext(this));
         ID     = client.Connect(Login, Password);
         client.UpdateUsersList();
         client.RoomListRequest(ID);
         tbUserName.IsEnabled = false;
         btnConnect.Content   = "Disconnect";
         isConnected          = true;
     }
 }
Exemplo n.º 16
0
        public ChatWindow(string userName)
        {
            InitializeComponent();

            client = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
            UserId = client.Connect(userName);
            if (UserId == 0)
            {
                ErrorWindow errorWindow = new ErrorWindow("Connection error!");
                errorWindow.ShowDialog();
                StartWindow startWindow = new StartWindow();
                startWindow.Show();
                Close();
            }
            DataContext = this;
        }
 // Метод подключения
 public void Connect()
 {
     // Если ещё не подключены, создаём пользователя, заносим в него данные и отправляем его сервису. Получаем обратно назначенный ИД
     if (!IsConnected)
     {
         ServerUser user = new ServerUser
         {
             Name  = tbUserName.Text,
             Room  = cmbGroup.SelectedIndex,
             Color = (NameColor)cmbColor.SelectedIndex
         };
         id = client.Connect(user);
         tbUserName.IsEnabled = false;
         btnConnect.Content   = "Отключиться";
         IsConnected          = true;
     }
 }
Exemplo n.º 18
0
        void ConnectUser()
        {
            if (!isConnected)
            {
                client           = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
                ID               = client.Connect(textBox1.Text);
                isConnected      = true;
                button1.Text     = "Отключиться";
                textBox1.Enabled = false;

                AllData [] field = client.GetData();
                for (int i = 0; i < field.Length; i++)
                {
                    listBox1.Items.Add(Convert.ToDateTime(field[i].Time).ToString("HH:mm:ss") + " " + field[i].Username + " " + field[i].Message);
                }
            }
        }
Exemplo n.º 19
0
        //--------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// подключение пользователя к сервису
        /// </summary>
        void ConnectUser()
        {
            if (!isConnected && !string.IsNullOrWhiteSpace(tbUserName.Text))
            {
                client   = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
                id       = client.Connect(out listUser, tbUserName.Text);
                nameCurr = tbUserName.Text;
                ShowListUsers(listUser);
                tbUserName.IsEnabled = false;
                bConnDiscon.Content  = "Disconnect";
                isConnected          = true;
            }
            else
            {
                MessageBox.Show("Введите имя пользователя");
            }
        }
Exemplo n.º 20
0
 void ConnectUser()
 {
     if (!isConnected)
     {
         try
         {
             client = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
             ID     = client.Connect(tbUserName.Text);
             tbUserName.IsEnabled = false;
             bConnDicon.Content   = "Disconnect";
             isConnected          = true;
         } catch (Exception ex)
         {
             tbMessage.Text = ex.ToString();
         }
     }
 }
Exemplo n.º 21
0
        public ChatFrame(string LoginFirst, string LoginSecond)
        {
            InitializeComponent();
            _LoginFirst  = LoginFirst;
            _LoginSecond = LoginSecond;


            client = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
            client.Connect(LoginFirst);
            client.CreateConversation(LoginFirst, LoginSecond);
            ChatUsers.Content = "чат с " + LoginSecond;
            List <string> ChatAllMessage = client.GetAllMessage(LoginFirst, LoginSecond).ToList();

            foreach (string message in ChatAllMessage)
            {
                GetMessage.Items.Add(message);
                GetMessage.ScrollIntoView(GetMessage.Items[GetMessage.Items.Count - 1]);
            }
        }
Exemplo n.º 22
0
        void connect()
        {
            if (!isConnect)
            {
                client = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));

                UserInLog = client.Connect(provider.GetAllUsers().FirstOrDefault(x => x.Name == tbName.Text));

                if (History.IsChecked == true)
                {
                    var allMsg = provider.GetAllMsg();

                    foreach (var item in allMsg)
                    {
                        try
                        {
                            var a = provider.GetAllUsers().FirstOrDefault(x => x.id == item.UserID);
                            MsgCallback(a, item.Message, TypeMsg.Message);
                            //chat.ItemsSource = provider.GetAllMsg();
                            //chat.SelectedValuePath = "Message";
                            //chat.SelectedValue = "Message";
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
                // MessageBox.Show(client.GetAllOnlineUsers().Length.ToString());
                ////Cписок онлайн юзерів

                listOnlineUsers.AddRange(client.GetAllOnlineUsers());

                listUsers.ItemsSource = listOnlineUsers;
                listUsers.Items.Refresh();
                tbName.IsEnabled = false;
                btnCon.Content   = "Disconnect";
                isConnect        = true;
            }
        }
Exemplo n.º 23
0
        void ConnectUser()
        {
            if (!isConnected)
            {
                client = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
                ID     = client.Connect(textBox2.Text);

                textBox2.Enabled = false;
                button1.Text     = "Выйти";
                var messages = client.ShowMsg(textBox2.Text);
                if (messages != null)
                {
                    foreach (var m in messages)
                    {
                        if (m != "")
                        {
                            listBox1.Items.Add(m);
                        }
                    }
                }
                isConnected = true;
            }
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                return;
            }
            client = new ServiceChatClient(new System.ServiceModel.InstanceContext(new Program()));
            id     = client.Connect(args[0]);



            while (true)
            {
                PrintMenu();
                Console.WriteLine("Input option");
                char key = Console.ReadKey().KeyChar;
                Console.WriteLine();
                switch (key)
                {
                case 'w':
                {
                    int    receiverId;
                    string mes;
                    lock (locker)
                    {
                        Console.WriteLine("Write receiver Id");
                        if (!Int32.TryParse(Console.ReadLine(), out receiverId))
                        {
                            Console.WriteLine("Wrong input!");
                            continue;
                        }
                        Console.WriteLine("Write message");
                        mes = Console.ReadLine();
                    }
                    client.SendMsg(mes, receiverId, id);
                }; break;

                case 'u':
                {
                    Console.WriteLine("Users ID: ");
                    var usersId = client.GetServerUsers();
                    for (int i = 0; i < usersId.Length; i++)
                    {
                        Console.Write(usersId[i] + " ");
                    }
                    Console.WriteLine();
                }; break;

                case 'i':
                {
                    Console.WriteLine("Your data:\n" +
                                      $"\tID - {id}\n" +
                                      $"\tNickName - {args[0]}"
                                      );
                }; break;

                case 'e':
                {
                    client.Disconnect(id);
                    Console.WriteLine("Disconnect...");
                    return;
                }

                default:
                {
                    Console.WriteLine("Wrong command!");
                    continue;
                }
                }
            }
        }
Exemplo n.º 25
0
 /// <summary>
 /// Конструктор по умолчанию.
 /// </summary>
 public ClientData()
 {
     client = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));
     client.Connect(new User());
 }