コード例 #1
0
        public async Task WhenSetClientConnectionEncryptionLevelSetToLow_ThenConnectionSucceeds(
            [WindowsInstance(InitializeScript = @"
                & reg add ""HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services"" /t REG_DWORD /v MinEncryptionLevel /d 1 /f | Out-Default
            ")] ResourceTask <InstanceLocator> testInstance,
            [Credential(Role = PredefinedRole.IapTunnelUser)] ResourceTask <ICredential> credential)
        {
            var locator = await testInstance;

            using (var tunnel = RdpTunnel.Create(
                       locator,
                       await credential))
            {
                var session = await Connect(tunnel, locator);

                AwaitEvent <ConnectionSuceededEvent>();
                Assert.IsNull(this.ExceptionShown);

                ConnectionClosedEvent expectedEvent = null;

                this.serviceProvider.GetService <IEventService>()
                .BindHandler <ConnectionClosedEvent>(e =>
                {
                    expectedEvent = e;
                });

                Delay(TimeSpan.FromSeconds(5));
                session.Close();

                Assert.IsNotNull(expectedEvent);
            }
        }
コード例 #2
0
 public virtual void OnDisconnected(ConnectionClosedEvent e)
 {
     if (Profile.Debug)
     {
         _.Log(e);
     }
 }
コード例 #3
0
 public ClientPeerConnection(IPEndPoint superPeerEndPoint, MessageReceivedEvent onMessageReceivedEvent,
     ConnectionClosedEvent onConnectionClosedEvent)
     : base(new JsonSerializer())
 {
     MessageReceivedEvent = onMessageReceivedEvent;
     ConnectionClosedEvent = onConnectionClosedEvent;
     Peer = new ClientPeer(superPeerEndPoint);
 }
コード例 #4
0
        private void Handle(ConnectionClosedEvent @event)
        {
            ConnectionPerformanceRecorder recorder;

            if (_connectionRecorders.TryRemove(@event.ConnectionId, out recorder))
            {
                recorder.Closed();
            }
        }
コード例 #5
0
 private void OnDisconnectedInternal(ConnectionClosedEvent e)
 {
     if (Profile.Debug)
     {
         _.Log(e);
     }
     Status.Connected = false;
     OnDisconnected(e);
 }
コード例 #6
0
        private void OnRdpConnectionClosed(ConnectionClosedEvent e)
        {
            var node = (VmInstanceNode)TryFindNode(e.Instance);

            if (node != null)
            {
                // Another connection might still be open, so re-check before
                // marking the node as not connected.
                node.IsConnected = this.connectionBroker.IsConnected(node.Reference);
            }
        }
コード例 #7
0
        public async Task WhenConnected_ThenActiveSessionIsSetAndTryActivateReturnsTrue(
            [WindowsInstance(MachineType = MachineTypeForRdp)] ResourceTask <InstanceLocator> testInstance,
            [Credential(Role = PredefinedRole.IapTunnelUser)] ResourceTask <ICredential> credential)
        {
            var locator = await testInstance;

            using (var tunnel = RdpTunnel.Create(
                       locator,
                       await credential))
                using (var gceAdapter = new ComputeEngineAdapter(this.serviceProvider.GetService <IAuthorizationAdapter>()))
                {
                    var credentials = await gceAdapter.ResetWindowsUserAsync(
                        locator,
                        CreateRandomUsername(),
                        TimeSpan.FromSeconds(60),
                        CancellationToken.None);

                    var settings = VmInstanceConnectionSettings.CreateNew(
                        locator.ProjectId,
                        locator.Name);
                    settings.Username.StringValue = credentials.UserName;
                    settings.Password.Value       = credentials.SecurePassword;

                    var broker  = new RemoteDesktopConnectionBroker(this.serviceProvider);
                    var session = broker.Connect(
                        locator,
                        "localhost",
                        (ushort)tunnel.LocalPort,
                        settings);

                    AwaitEvent <ConnectionSuceededEvent>();
                    Assert.IsNull(this.ExceptionShown);

                    Assert.IsTrue(broker.IsConnected(locator));
                    Assert.AreSame(session, broker.ActiveSession);
                    Assert.IsTrue(broker.TryActivate(locator));

                    Assert.IsFalse(broker.TryActivate(SampleLocator));
                    Assert.IsFalse(broker.IsConnected(SampleLocator));

                    ConnectionClosedEvent expectedEvent = null;

                    this.serviceProvider.GetService <IEventService>()
                    .BindHandler <ConnectionClosedEvent>(e =>
                    {
                        expectedEvent = e;
                    });
                    session.Close();

                    Assert.IsNotNull(expectedEvent);
                }
        }
コード例 #8
0
    protected virtual void OnConnectClosed(ConnectionClosedEvent e)
    {
        //Đã có thông báo nào đó trước rồi. Và đã disconnect rồi
        if (GameManager.Instance.currentRoom == null)
        {
            return;
        }

        Debug.LogWarning("ConnectClosed: Server Disconnect.....!");

        WhenDisconnect();

        if (GameManager.CurrentScene != ESceneName.LoginScreen)
        {
            NotificationView.ShowMessage("Bạn đã bị mất kết nối đến với máy chủ !");
        }
    }
コード例 #9
0
        public void Close()
        {
            lock (SocketMonitor)
            {
                try
                {
                    StopListeningMessages();
                    ClientSocket.Close();
                }
                catch (SocketException se)
                {
                    Trace.WriteLine("SocketException: " + se.ErrorCode + " " + se.Message);
                }

                if (ConnectionClosedEvent != null)
                {
                    ConnectionClosedEvent.Invoke(this, new EventArgs());
                }
            }
        }
コード例 #10
0
ファイル: WsStream.cs プロジェクト: encodeous/wstream
 internal void InternalClose(bool remote = false)
 {
     _cancellationTokenSource.Cancel();
     ConnectionClosedEvent?.Invoke(this);
 }
コード例 #11
0
 protected virtual void OnConnectionClosed()
 {
     ConnectionClosedEvent?.Invoke(this, EventArgs.Empty);
 }
コード例 #12
0
 public void OnConnectionClosedEvent(ConnectionClosedEvent evt)
 {
     waitingMessage = "Connection to the server has been lost.  Refresh to continue.";
     inLobby = false;
     Debug.Log(waitingMessage);
 }
コード例 #13
0
        public async Task WhenCredentialsValid_ThenConnectingSucceeds(
            [Values(RdpConnectionBarState.AutoHide, RdpConnectionBarState.Off, RdpConnectionBarState.Pinned)]
            RdpConnectionBarState connectionBarState,

            [Values(RdpDesktopSize.ClientSize, RdpDesktopSize.ScreenSize)]
            RdpDesktopSize desktopSize,

            [Values(RdpAudioMode.DoNotPlay, RdpAudioMode.PlayLocally, RdpAudioMode.PlayOnServer)]
            RdpAudioMode audioMode,

            [Values(RdpRedirectClipboard.Disabled, RdpRedirectClipboard.Enabled)]
            RdpRedirectClipboard redirectClipboard,

            // Use a slightly larger machine type as all this RDP'ing consumes a fair
            // amount of memory.
            [WindowsInstance(MachineType = "n1-standard-2")] ResourceTask <InstanceLocator> testInstance,
            [Credential(Role = PredefinedRole.IapTunnelUser)] ResourceTask <ICredential> credential)
        {
            var locator = await testInstance;

            using (var tunnel = RdpTunnel.Create(
                       locator,
                       await credential))
                using (var gceAdapter = new ComputeEngineAdapter(this.serviceProvider.GetService <IAuthorizationAdapter>()))
                {
                    var credentials = await gceAdapter.ResetWindowsUserAsync(
                        locator,
                        CreateRandomUsername(),
                        TimeSpan.FromSeconds(60),
                        CancellationToken.None);

                    var settings = VmInstanceConnectionSettings.CreateNew(
                        locator.ProjectId,
                        locator.Name);
                    settings.Username.StringValue          = credentials.UserName;
                    settings.Password.Value                = credentials.SecurePassword;
                    settings.ConnectionBar.EnumValue       = connectionBarState;
                    settings.DesktopSize.EnumValue         = desktopSize;
                    settings.AudioMode.EnumValue           = audioMode;
                    settings.RedirectClipboard.EnumValue   = redirectClipboard;
                    settings.AuthenticationLevel.EnumValue = RdpAuthenticationLevel.NoServerAuthentication;
                    settings.BitmapPersistence.EnumValue   = RdpBitmapPersistence.Disabled;

                    var rdpService = new RemoteDesktopConnectionBroker(this.serviceProvider);
                    var session    = rdpService.Connect(
                        locator,
                        "localhost",
                        (ushort)tunnel.LocalPort,
                        settings);

                    AwaitEvent <ConnectionSuceededEvent>();
                    Assert.IsNull(this.ExceptionShown);


                    ConnectionClosedEvent expectedEvent = null;

                    this.serviceProvider.GetService <IEventService>()
                    .BindHandler <ConnectionClosedEvent>(e =>
                    {
                        expectedEvent = e;
                    });
                    session.Close();

                    Assert.IsNotNull(expectedEvent);
                }
        }
コード例 #14
0
 public void Handle(ConnectionClosedEvent message)
 {
     ServerName = string.Empty;
 }
コード例 #15
0
ファイル: Session.cs プロジェクト: blowfish64/CLR-DEV9
 protected void RaiseEventConnectionClosed()
 {
     ConnectionClosedEvent?.Invoke(this, new EventArgs());
 }
コード例 #16
0
 private void Handle(ConnectionClosedEvent @event)
 {
     Debug(TraceSourceEventHelper.ConnectionIdBase + 4, "{0}: closed.", TraceSourceEventHelper.Label(@event.ConnectionId));
 }
コード例 #17
0
 public void OnConnectionClosedEvent(ConnectionClosedEvent evt)
 {
     string msg = "Connection to the server has been lost.  Refresh to continue.";
     SendMessage("AddChatMessage", msg);
     Log(msg);
 }
コード例 #18
0
 public void Apply(ConnectionClosedEvent evt)
 {
     State = new ConnectionStateContext(ConnectionStateEnum.Closed);
 }
コード例 #19
0
 private void NotifyConnectionClosed()
 {
     _Logger.Info("Connection was shut down");
     ConnectionClosedEvent?.Invoke(this);
 }