示例#1
0
        static void Main(string[] args)
        {
            int port = 8001;
            string ip = "127.0.0.1";
            //            string ip = "172.17.50.45";

            ChatClient chatClient = null;
            ChatClient chatClient2 = null;

            try
            {
                chatClient = new ChatClient(ip, port);
                chatClient2 = new ChatClient(ip, port);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }

            //Decomenteaza liniile ca sa creezi useri
            chatClient.SignUp("Dinu", "MyPassword");
            chatClient2.SignUp("George", "HisPassword");

            chatClient.SignIn("Dinu", "MyPassword");

            Thread.Sleep(100);

            chatClient2.SignIn("George", "HisPassword");
            //            Console.WriteLine("Sending friend request");

            //chatClient.SendFriendRequest("George");
            chatClient2.SendFriendRequest("Dinu");

            chatClient.SetMessageReceiver(ReceiveMessage);
            chatClient2.SetMessageReceiver(ReceiveMessage);
            chatClient.SetFileReceiver(ConfirmFileReceivement,GetSavePath);
            chatClient2.SetFileReceiver(ConfirmFileReceivement, GetSavePath);

            chatClient.SendMessage("George", "Hi George");

            //            chatClient.SendFile("George", @"C:\nap3.gif");
            chatClient.ChangeStatus("Dinu Status");

            chatClient.SignOut();
            chatClient2.SignOut();
        }
 void binding_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     try
     {
         if (!String.IsNullOrWhiteSpace(tbMessage.Text))
         {
             if ((Tabs.SelectedItem as ClosableTab).Tag is UserInfo)
             {
                 client.SendMessageTo((Tabs.SelectedItem as ClosableTab).Tag as UserInfo, tbMessage.Text);
             }
             else if ((Tabs.SelectedItem as ClosableTab).Title.ToString() == "Lobby")
             {
                 client.SendMessage(tbMessage.Text);
             }
         }
         tbMessage.Text = "";
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }