internal override UserToUserResponse ProcessWithEngagement(Engagement engagement, UserToUserRequest req)
        {
            RDPRequestResponseRq request  = (RDPRequestResponseRq)req;
            RDPRequestResponseRs response = new RDPRequestResponseRs();

            try
            {
                ((Function)engagement.GetFunction("RemoteDesktop")).ProcessRemoteDesktopRequestResponse(request);
            }
            catch (Exception e)
            {
                Logger.Error("Failed to process incoming RDP request response : " + e.Message, e);
                response.error        = "INTERNAL_SERVER_ERROR";
                response.errorMessage = "Failed to process incoming RDP request response";
            }
            return(response);
        }
Exemple #2
0
        // generic method to send a response to the remote desktop request
        private void SendRdpRequestResponse(bool answer, String connectionId, Action <RDPRequestResponseRq, RDPRequestResponseRs, Exception> handler)
        {
            // compile the request
            RDPRequestResponseRq request = new RDPRequestResponseRq()
            {
                accepted      = answer,
                shortCode     = _engagement.SecondParty.ActiveShortCode,
                username      = _engagement.SecondParty.Party.Username,
                interactionId = _engagement.Interactions.CurrentOrNewInteraction.Id,
                connectionId  = connectionId,
            };

            try
            {
                // Send the request asynchronously
                _appContext.ConnectionManager.Connection.RequestAsync <RDPRequestResponseRq, RDPRequestResponseRs>(
                    request, handler);
            }
            catch (Exception e)
            {
                Logger.Error("Failed to send a RDP request (answer=" + answer + ") to " + _engagement.SecondParty.Party.Username, e);
            }
        }
Exemple #3
0
        /*
         * // This is called once our async request to second party to control his desktop has completed
         * private void ProcessRequestRDPSessionResponse(RDPRequestRq request, RDPRequestRs response, Exception e, IChatMessage chatElement)
         * {
         *
         *  if (e != null)
         *  {
         *      if (e is MessageException<RDPRequestRs>)
         *      {
         *          var exception = (MessageException<RDPRequestRs>)e;
         *          if ("WILL_NOT_PROCESS_ELEVATE".Equals(exception.ErrorCode))
         *          {
         *              // need elevation
         *              string tokenId;
         *              string securityKey;
         *              if (BlitsMeClientAppContext.CurrentAppContext.Elevate(
         *                  "This connection requires you to verify your identify, please enter your BlitsMe password to connect to " +
         *                  _engagement.SecondParty.Person.Name + ".",
         *                  out tokenId, out securityKey))
         *              {
         *                  RequestRdpSession(tokenId, securityKey);
         *              }
         *              else
         *              {
         *                  Chat.LogErrorMessage("Failed to elevate privileges to connect to " +
         *                                       _engagement.SecondParty.Person.Name);
         *              }
         *          }
         *      }
         *      else
         *      {
         *          // The message wasn't delivered
         *          IsActive = false;
         *          Logger.Error("Received a async response to " + request.id + " that is an error", e);
         *      }
         *  }
         *  else
         *  {
         *      // The message was delivered
         *      IsActive = true;
         *      // Raise an activity that we managed to send a rdp request to second party successfully.
         *      OnNewActivity(new RemoteDesktopActivity(_engagement, RemoteDesktopActivity.REMOTE_DESKTOP_REQUEST) { From = "_SELF", To = _engagement.SecondParty.Person.Username });
         *  }
         * }
         */

        // this is called by the request manager when we receive a answer our remote desktop request (yes or no)
        internal void ProcessRemoteDesktopRequestResponse(RDPRequestResponseRq request)
        {
            // Hey, we received an answer, note the activity
            OnNewActivity(new RemoteDesktopActivity(_engagement, RemoteDesktopActivity.REMOTE_DESKTOP_RESPONSE)
            {
                To = "_SELF", From = _engagement.SecondParty.Party.Username, Answer = request.accepted
            });
            if (request.accepted)
            {
                // ok, he wants us to control his desktop
                IsActive = true;
                // note that we are go to remote control second partys desktop
                //_engagement.IsRemoteControlActive = true;
                // print message in chat that we are about to go ahead and connect
                Chat.LogSecondPartySystemMessage(_engagement.SecondParty.Party.Firstname + " accepted your remote assistance request, please wait while we establish a connection...");
                try
                {
                    int    port       = Client.Start(request.connectionId);
                    String viewerExe  = System.IO.Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]) + "\\gwupess.exe";
                    var    parameters = "-username=\"" + _engagement.SecondParty.Party.Name + "\" -copyrect=yes -encoding=tight -compressionlevel=9 -jpegimagequality=3 -scale=auto -host=localhost -port=" + port;
                    Logger.Debug("Running " + viewerExe + " " + parameters);
                    _bmssHandle = Process.Start(viewerExe, parameters);
                }
                catch (Exception e)
                {
                    Chat.LogErrorMessage("Failed to create a connection to " + _engagement.SecondParty.Party.Username);
                    IsActive = false;
                    Logger.Error("Failed to start RDP client to " + _engagement.SecondParty.Party.Username + " : " + e.Message, e);
                    throw e;
                }
            }
            else
            {
                IsActive = false;
                Chat.LogSecondPartySystemMessage(_engagement.SecondParty.Party.Firstname + " did not accept your remote assistance request.");
            }
        }