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); } }
public virtual void OnDisconnected(ConnectionClosedEvent e) { if (Profile.Debug) { _.Log(e); } }
public ClientPeerConnection(IPEndPoint superPeerEndPoint, MessageReceivedEvent onMessageReceivedEvent, ConnectionClosedEvent onConnectionClosedEvent) : base(new JsonSerializer()) { MessageReceivedEvent = onMessageReceivedEvent; ConnectionClosedEvent = onConnectionClosedEvent; Peer = new ClientPeer(superPeerEndPoint); }
private void Handle(ConnectionClosedEvent @event) { ConnectionPerformanceRecorder recorder; if (_connectionRecorders.TryRemove(@event.ConnectionId, out recorder)) { recorder.Closed(); } }
private void OnDisconnectedInternal(ConnectionClosedEvent e) { if (Profile.Debug) { _.Log(e); } Status.Connected = false; OnDisconnected(e); }
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); } }
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); } }
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ủ !"); } }
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()); } } }
internal void InternalClose(bool remote = false) { _cancellationTokenSource.Cancel(); ConnectionClosedEvent?.Invoke(this); }
protected virtual void OnConnectionClosed() { ConnectionClosedEvent?.Invoke(this, EventArgs.Empty); }
public void OnConnectionClosedEvent(ConnectionClosedEvent evt) { waitingMessage = "Connection to the server has been lost. Refresh to continue."; inLobby = false; Debug.Log(waitingMessage); }
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); } }
public void Handle(ConnectionClosedEvent message) { ServerName = string.Empty; }
protected void RaiseEventConnectionClosed() { ConnectionClosedEvent?.Invoke(this, new EventArgs()); }
private void Handle(ConnectionClosedEvent @event) { Debug(TraceSourceEventHelper.ConnectionIdBase + 4, "{0}: closed.", TraceSourceEventHelper.Label(@event.ConnectionId)); }
public void OnConnectionClosedEvent(ConnectionClosedEvent evt) { string msg = "Connection to the server has been lost. Refresh to continue."; SendMessage("AddChatMessage", msg); Log(msg); }
public void Apply(ConnectionClosedEvent evt) { State = new ConnectionStateContext(ConnectionStateEnum.Closed); }
private void NotifyConnectionClosed() { _Logger.Info("Connection was shut down"); ConnectionClosedEvent?.Invoke(this); }