public MainForm() { InitializeComponent(); AlignWindow(); //Start Dinu! Stream stream = File.Open("config.info", FileMode.Open); BinaryFormatter bformatter = new BinaryFormatter(); bformatter = new BinaryFormatter(); ConnectingSettingsData info = (ConnectingSettingsData)bformatter.Deserialize(stream); stream.Close(); int port = Int32.Parse(info.port); _chatClient = new ChatClient(info.ip, port); _chatClient.SetMessageReceiver(ReceiveMessage); _chatClient.SetFileReceiver(ConfirmFileReceivement, GetSavePath); _chatClient.SetFriendRequestConfirmation(ConfirmFriendRequest); _chatClient.SetNotifier(Notify); //or in other place //End Dinu! }
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(); }
public void UpdateChatClient(string ip, int port) { _chatClient.SignOut(); _chatClient = new ChatClient(ip, port); _chatClient.SetMessageReceiver(ReceiveMessage); _chatClient.SetFileReceiver(ConfirmFileReceivement, GetSavePath); _chatClient.SetFriendRequestConfirmation(ConfirmFriendRequest); _chatClient.SetNotifier(Notify); }