private void OnStatusReceived(object sender, MessageReceivedArgs e) { logger.LogDebug( "Status-Nachricht empfangen: {content}", e.Content); if (sessionStartRegex.IsMatch(e.Content)) { SessionStartedEvent?.Invoke( sender: this, e: null); } else { var sessionStatusText = sessionStatusRegex.IsMatch(e.Content) ? sessionStatusRegex.Match(e.Content).Groups[StatusRegexGroupName].Value : default; var sessionStatus = sessionStatusText.GetSessionStatusType(); if (sessionStatus == default) { logger.LogError( "Unbekannte Status-Nachricht empfangen: {content}", e.Content); } else { SendSessionStatus(sessionStatus.Value); } } }
private void OnRdpSessionStarted(SessionStartedEvent e) { var node = (VmInstanceNode)TryFindNode(e.Instance); if (node != null) { node.IsConnected = true; } }
public Session StartSession(int gameId, int actorId) { var session = new Session(gameId, actorId); _sessions.TryAdd(session.Id, session); SessionStartedEvent?.Invoke(session); _logger.LogInformation($"SessionId: {session.Id} for GameId: {gameId}, ActorId: {actorId}"); return(session); }
private async Task <SshTerminalPane> ConnectSshTerminalPane( InstanceLocator instanceLocator, ICredential credential, CultureInfo language = null) { var authorization = new Mock <IAuthorization>(); authorization .SetupGet(a => a.Email) .Returns("*****@*****.**"); var authorizationAdapter = new Mock <IAuthorizationAdapter>(); authorizationAdapter .Setup(a => a.Authorization) .Returns(authorization.Object); using (var keyAdapter = new AuthorizedKeyService( authorizationAdapter.Object, new ComputeEngineAdapter(credential), new ResourceManagerAdapter(credential), new Mock <IOsLoginService>().Object)) { var authorizedKey = await keyAdapter.AuthorizeKeyAsync( instanceLocator, new RsaSshKey(new RSACng()), TimeSpan.FromMinutes(10), null, AuthorizeKeyMethods.InstanceMetadata, CancellationToken.None) .ConfigureAwait(true); // Connect and wait for event SessionStartedEvent connectedEvent = null; this.eventService.BindHandler <SessionStartedEvent>(e => connectedEvent = e); var broker = new SshTerminalSessionBroker( this.serviceProvider); var pane = await broker.ConnectAsync( instanceLocator, new IPEndPoint(await PublicAddressFromLocator(instanceLocator), 22), authorizedKey, language, TimeSpan.FromSeconds(10)) .ConfigureAwait(true); Assert.IsNotNull(connectedEvent, "ConnectionSuceededEvent event fired"); PumpWindowMessages(); return((SshTerminalPane)pane); } }
public async Task WhenAuthenticationSucceeds_ThenConnectionSuceededEventEventIsFired( [LinuxInstance] ResourceTask <InstanceLocator> instanceLocatorTask, [Credential(Role = PredefinedRole.ComputeInstanceAdminV1)] ResourceTask <ICredential> credential) { SessionStartedEvent connectedEvent = null; this.eventService.BindHandler <SessionStartedEvent>(e => connectedEvent = e); using (var pane = await ConnectSshTerminalPane( await instanceLocatorTask, await credential)) { // Close the pane (not the window). pane.Close(); Assert.IsNotNull(connectedEvent, "ConnectionSuceededEvent event fired"); } }