Пример #1
0
        private void OnContextCreated(IntPtr frgContext)
        {
            _frgContext = frgContext;

            if (_exitError != null)
            {
                FreeRdpGlue.Disconnect(_frgContext);
                return;
            }
        }
Пример #2
0
        public void Start(RdpBridgeStartOptions options)
        {
            _running = true;

            StartIngressThread();

            _channel.WriteDelimited(new SessionMessage
            {
                SessionStart = new SessionStartMessage
                {
                    SessionId = options.SessionId,
                }
            });

            FreeRdpGlue.Main(new MainOptions
            {
                Hostname    = options.Host,
                Username    = options.Username,
                Password    = options.Password,
                Domain      = options.Domain,
                EntryPoints = new EntryPoints
                {
                    OnContextCreated    = OnContextCreated,
                    OnAuthenticate      = OnAuthenticate,
                    OnVerifyCertificate = FrgOnVerifyCertificateFn,
                    UpdateCallbacks     = new UpdateCallbacks
                    {
                    }
                }
            });

            _channel.WriteDelimited(new RdpMessage
            {
                SessionEnd = new RdpSessionEndMessage {
                },
            });

            _running = false;
            Console.WriteLine("YYY 1");
            _inputThread.Join();
            Console.WriteLine("YYY 2");
            _channel.Close();
            Console.WriteLine("YYY 3");

            if (_exitError != null)
            {
                throw _exitError;
            }
        }
Пример #3
0
        private void StartIngressThread()
        {
            _inputThread = new Thread(() =>
            {
                try
                {
                    while (_running)
                    {
                        if (!_channel.ReadDelimited(out RdpMessage rdpMessage))
                        {
                            _running = false;
                            continue;
                        }

                        Console.WriteLine($"XXX {rdpMessage.MessageCase}");
                        switch (rdpMessage.MessageCase)
                        {
                        case RdpMessage.MessageOneofCase.VerifyCertificateResult:
                            _rdpVerifyCertificateResultMessage.Set(rdpMessage.VerifyCertificateResult);
                            break;

                        case RdpMessage.MessageOneofCase.AuthenticateResult:
                            _rdpAuthenticateResultMessage.Set(rdpMessage.AuthenticateResult);
                            break;

                        case RdpMessage.MessageOneofCase.Disconnect:
                            FreeRdpGlue.Disconnect(_frgContext);
                            break;

                        case RdpMessage.MessageOneofCase.SessionEnd:
                            _running = false;
                            break;
                        }
                    }
                }
                catch (Exception e)
                {
                    _exitError = e;

                    if (_frgContext != IntPtr.Zero)
                    {
                        FreeRdpGlue.Disconnect(_frgContext);
                    }
                }
            });
            _inputThread.Start();
        }