/* * When a user click the diconnect button, this function will disconnect to the remote service and send a * logout type message to the server. */ private void Button_Click_Disconnect(object sender, RoutedEventArgs e) { if (remoteService != null && isConnected == true) { isConnected = false; t.Abort(); string messageType = "logout"; string message = messageType + "|" + UserName; remoteService.SendMessage(message); remoteService = null; //System.Windows.Application.Current.Shutdown(); } }
/* * When a user click the login button, this function will connect to the remote service and send a * login type message to the server. */ private void Button_Click_Login(object sender, RoutedEventArgs e) { if (isConnected == false) { isConnected = true; remoteService = (IRomote.IRemoteInterface)Activator.GetObject( typeof(IRomote.IRemoteInterface), "tcp://localhost:12345/Server"); t = new Thread(Receive_Message); t.Start(); UserName = NameBox.Text; string messageType = "login"; string message = messageType + "|" + UserName; remoteService.SendMessage(message); } }