Example #1
0
 void MainWindow_Closing(object sender, CancelEventArgs e)
 {
     if (remoteService != null && isConnected == true)
     {
         //Your code to handle the event
         string messageType = "logout";
         string message     = messageType + "|" + UserName;
         remoteService.SendMessage(message);
     }
 }
Example #2
0
 /*
  * 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);
     }
 }