Ejemplo n.º 1
0
        private void InputsPipeConnected(IAsyncResult e)
        {
            try
            {
                if (InputsPipe != null)
                {
                    InputsPipe.EndWaitForConnection(e);

                    // send connection settings
                    RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendServerAddress, string.IsNullOrEmpty(RemoteSession.ServerAddress) ? "localhost" : RemoteSession.ServerAddress);

                    if (!string.IsNullOrEmpty(RemoteSession.VMGuid))
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendVMGuid, string.Concat(RemoteSession.VMGuid, string.Format(";EnhancedMode={0}", RemoteSession.VMEnhancedMode ? "1" : "0")));
                    }

                    if (!string.IsNullOrEmpty(RemoteSession.UserDomain))
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendUserDomain, RemoteSession.UserDomain);
                    }

                    if (!string.IsNullOrEmpty(RemoteSession.UserName))
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendUserName, RemoteSession.UserName);
                    }

                    if (!string.IsNullOrEmpty(RemoteSession.UserPassword))
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendUserPassword, RemoteSession.UserPassword);
                    }

                    if (!string.IsNullOrEmpty(RemoteSession.StartProgram))
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendStartProgram, RemoteSession.StartProgram);
                    }

                    // (re)sync the clipboard
                    if (!string.IsNullOrEmpty(RemoteSession.ClipboardText))
                    {
                        // send the clipboard text as unicode code points (same as done from the browser)
                        var clipboardUnicode = string.Empty;
                        foreach (var charValue in RemoteSession.ClipboardText)
                        {
                            clipboardUnicode += (string.IsNullOrEmpty(clipboardUnicode) ? string.Empty : "-") + char.ConvertToUtf32(charValue.ToString(), 0);
                        }
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendLocalClipboard, clipboardUnicode);
                    }

                    // connect the host client to the remote host; a fullscreen update will be sent upon connection
                    RemoteSession.Manager.SendCommand(RemoteSessionCommand.ConnectClient);
                }
            }
            catch (Exception exc)
            {
                Trace.TraceError("Failed to wait for connection on inputs pipe, remote session {0} ({1})", RemoteSession?.Id, exc);
            }
        }
Ejemplo n.º 2
0
        private void InputsPipeConnected(IAsyncResult e)
        {
            try
            {
                if (InputsPipe != null)
                {
                    InputsPipe.EndWaitForConnection(e);

                    // send connection settings
                    RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendServerAddress, string.IsNullOrEmpty(RemoteSession.ServerAddress) ? "localhost" : RemoteSession.ServerAddress);

                    if (!string.IsNullOrEmpty(RemoteSession.UserDomain))
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendUserDomain, RemoteSession.UserDomain);
                    }

                    if (!string.IsNullOrEmpty(RemoteSession.UserName))
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendUserName, RemoteSession.UserName);
                    }

                    if (!string.IsNullOrEmpty(RemoteSession.UserPassword))
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendUserPassword, RemoteSession.UserPassword);
                    }

                    if (!string.IsNullOrEmpty(RemoteSession.StartProgram))
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendStartProgram, RemoteSession.StartProgram);
                    }

                    // send browser settings, if defined (they will be otherwise send later by the browser)
                    if (RemoteSession.ImageEncoding.HasValue)
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SetImageEncoding, ((int)RemoteSession.ImageEncoding).ToString());
                    }

                    if (RemoteSession.ImageQuality.HasValue)
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SetImageQuality, RemoteSession.ImageQuality.ToString());
                    }

                    if (RemoteSession.ImageQuantity.HasValue)
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SetImageQuantity, RemoteSession.ImageQuantity.ToString());
                    }

                    // connect the host client to the remote host; a fullscreen update will be sent upon connection
                    RemoteSession.Manager.SendCommand(RemoteSessionCommand.ConnectClient);
                }
            }
            catch (Exception exc)
            {
                Trace.TraceError("Failed to wait for connection on inputs pipe, remote session {0} ({1})", RemoteSession.Id, exc);
            }
        }
Ejemplo n.º 3
0
 private void InputsPipeConnected(IAsyncResult e)
 {
     try
     {
         if (InputsPipe != null)
         {
             InputsPipe.EndWaitForConnection(e);
         }
     }
     catch (Exception exc)
     {
         Trace.TraceError("Failed to wait for connection on inputs pipe, remote session {0} ({1})", RemoteSession.Id, exc);
     }
 }
Ejemplo n.º 4
0
        private void InputsPipeConnected(IAsyncResult e)
        {
            try
            {
                if (InputsPipe != null)
                {
                    InputsPipe.EndWaitForConnection(e);

                    // send connection settings
                    RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendServerAddress, string.IsNullOrEmpty(RemoteSession.ServerAddress) ? "localhost" : RemoteSession.ServerAddress);

                    if (!string.IsNullOrEmpty(RemoteSession.VMGuid))
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendVMGuid, string.Concat(RemoteSession.VMGuid, string.Format(";EnhancedMode={0}", RemoteSession.VMEnhancedMode ? "1" : "0")));
                    }

                    if (!string.IsNullOrEmpty(RemoteSession.UserDomain))
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendUserDomain, RemoteSession.UserDomain);
                    }

                    if (!string.IsNullOrEmpty(RemoteSession.UserName))
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendUserName, RemoteSession.UserName);
                    }

                    if (!string.IsNullOrEmpty(RemoteSession.UserPassword))
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendUserPassword, RemoteSession.UserPassword);
                    }

                    if (!string.IsNullOrEmpty(RemoteSession.StartProgram))
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SendStartProgram, RemoteSession.StartProgram);
                    }

                    // connect the host client to the remote host; a fullscreen update will be sent upon connection
                    RemoteSession.Manager.SendCommand(RemoteSessionCommand.ConnectClient);
                }
            }
            catch (Exception exc)
            {
                Trace.TraceError("Failed to wait for connection on inputs pipe, remote session {0} ({1})", RemoteSession.Id, exc);
            }
        }
Ejemplo n.º 5
0
        public void CreatePipes()
        {
            try
            {
                // close the pipes if already exist; they will be re-created below
                DeletePipes();

                // set the pipes access rights
                var pipeSecurity   = new PipeSecurity();
                var pipeAccessRule = new PipeAccessRule(AccountHelper.GetEveryoneGroupName(), PipeAccessRights.ReadWrite, AccessControlType.Allow);
                pipeSecurity.AddAccessRule(pipeAccessRule);

                // create the pipes
                _inputsPipe = new NamedPipeServerStream(
                    "remotesession_" + RemoteSession.Id + "_inputs",
                    PipeDirection.InOut,
                    1,
                    PipeTransmissionMode.Message,
                    PipeOptions.Asynchronous,
                    InputsPipeBufferSize,
                    InputsPipeBufferSize,
                    pipeSecurity);

                _updatesPipe = new NamedPipeServerStream(
                    "remotesession_" + RemoteSession.Id + "_updates",
                    PipeDirection.InOut,
                    1,
                    PipeTransmissionMode.Message,
                    PipeOptions.Asynchronous,
                    UpdatesPipeBufferSize,
                    UpdatesPipeBufferSize,
                    pipeSecurity);

                // wait for client connection
                InputsPipe.BeginWaitForConnection(InputsPipeConnected, InputsPipe.GetHashCode());
                UpdatesPipe.BeginWaitForConnection(UpdatesPipeConnected, UpdatesPipe.GetHashCode());
            }
            catch (Exception exc)
            {
                Trace.TraceError("Failed to create pipes, remote session {0} ({1})", RemoteSession.Id, exc);
            }
        }
Ejemplo n.º 6
0
        public void CreatePipes()
        {
            try
            {
                // close the pipes if already exist; they will be re-created below
                DeletePipes();

                // set the pipes access rights
                var pipeSecurity   = new PipeSecurity();
                var pipeAccessRule = new PipeAccessRule(RemoteSession.Manager.Client.GetProcessIdentity(), PipeAccessRights.FullControl, AccessControlType.Allow);
                pipeSecurity.AddAccessRule(pipeAccessRule);

                // create the pipes
                _inputsPipe = new NamedPipeServerStream(
                    "remotesession_" + RemoteSession.Id + "_inputs",
                    PipeDirection.InOut,
                    1,
                    PipeTransmissionMode.Byte,
                    PipeOptions.Asynchronous,
                    0,
                    0,
                    pipeSecurity);

                _updatesPipe = new NamedPipeServerStream(
                    "remotesession_" + RemoteSession.Id + "_updates",
                    PipeDirection.InOut,
                    1,
                    PipeTransmissionMode.Byte,
                    PipeOptions.Asynchronous,
                    0,
                    0,
                    pipeSecurity);

                // wait for client connection
                InputsPipe.BeginWaitForConnection(InputsPipeConnected, InputsPipe);
                UpdatesPipe.BeginWaitForConnection(UpdatesPipeConnected, UpdatesPipe);
            }
            catch (Exception exc)
            {
                Trace.TraceError("Failed to create pipes, remote session {0} ({1})", RemoteSession.Id, exc);
            }
        }
Ejemplo n.º 7
0
        private void InputsPipeConnected(IAsyncResult e)
        {
            try
            {
                if (InputsPipe != null)
                {
                    InputsPipe.EndWaitForConnection(e);

                    // remote session is now connected
                    RemoteSession.State = RemoteSessionState.Connected;

                    // send client settings, if defined (they will be otherwise send later by the client)
                    if (RemoteSession.ImageEncoding.HasValue)
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SetImageEncoding, ((int)RemoteSession.ImageEncoding).ToString());
                    }

                    if (RemoteSession.ImageQuality.HasValue)
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SetImageQuality, RemoteSession.ImageQuality.ToString());
                    }

                    if (RemoteSession.ImageQuantity.HasValue)
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.SetImageQuantity, RemoteSession.ImageQuantity.ToString());
                    }

                    if (RemoteSession.Manager.FullscreenEventPending)
                    {
                        RemoteSession.Manager.SendCommand(RemoteSessionCommand.RequestFullscreenUpdate);
                    }
                }
            }
            catch (Exception exc)
            {
                Trace.TraceError("Failed to wait for connection on inputs pipe, remote session {0} ({1})", RemoteSession.Id, exc);
            }
        }