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

            try
            {
                ((Function)engagement.GetFunction("RemoteDesktop")).ProcessIncomingRemoteDesktopRequest(request.shortCode);
            } catch (Exception e)
            {
                Logger.Error("Failed to process incoming RDP request : " + e.Message, e);
                response.error        = "INTERNAL_SERVER_ERROR";
                response.errorMessage = "Failed to process incoming RDP request";
            }
            return(response);
        }
예제 #2
0
        // Called When this user send a rdp request to the second party
        private void RequestRdpSession(ElevateToken token)
        {
            // now we compile the request to second party to control his desktop
            RDPRequestRq request = new RDPRequestRq()
            {
                shortCode     = _engagement.SecondParty.ActiveShortCode,
                username      = _engagement.SecondParty.Party.Username,
                interactionId = _engagement.Interactions.CurrentOrNewInteraction.Id,
                securityKey   = token?.SecurityKey,
                tokenId       = token?.TokenId,
            };

            try
            {
                // Actually send the message asynchronously
                //_appContext.ConnectionManager.Connection.RequestAsync<RDPRequestRq, RDPRequestRs>(request, (req, res, ex) => ProcessRequestRDPSessionResponse(req, res, ex, chatElement));
                try
                {
                    // if its unattended, indicate this
                    if (token != null)
                    {
                        Chat.LogSystemMessage("You have unattended access to their desktop, you will be granted access automatically after 10 seconds.");
                    }
                    else
                    {
                        // Print in chat that we sent the second party a rdp request
                        Chat.LogSystemMessage("You sent " + _engagement.SecondParty.Party.Firstname + " a request to control their desktop.");
                    }
                    var response = _appContext.ConnectionManager.Connection.Request <RDPRequestRq, RDPRequestRs>(request);
                    // 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.Party.Username
                    });
                }
                catch (MessageException <RDPRequestRs> e)
                {
                    if ("WILL_NOT_PROCESS_ELEVATE".Equals(e.ErrorCode) && (token == null))
                    {
                        // need elevation
                        ElevatedRequestRdpSession();
                    }
                    else if ("WILL_NOT_PROCESS_AUTH".Equals(e.ErrorCode))
                    {
                        Chat.LogErrorMessage("Sorry, you entered your password incorrectly.  Please try again.");
                    }
                    else if ("KEY_NOT_FOUND".Equals(e.ErrorCode))
                    {
                        // sometimes the user disappears and comes back with another shortcode, lets try that
                        if (_engagement.SecondParty.Presence.IsOnline &&
                            !_engagement.SecondParty.ActiveShortCode.Equals(_engagement.SecondParty.Presence.ShortCode))
                        {
                            Logger.Debug("ActiveShortCode is different from current presence shortcode, trying the new one");
                            _engagement.SecondParty.ActiveShortCode = _engagement.SecondParty.Presence.ShortCode;
                            RequestRdpSession(token);
                        }
                        else
                        {
                            throw;
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Error during request for RDP Session : " + ex.Message, ex);
                Chat.LogErrorMessage("An error occured trying to send " + _engagement.SecondParty.Party.Firstname + " a request to control their desktop.");
            }
        }