public void HeartbeatShouldLogFailure() { var formatter = new CommsLogEventFormatter(); var logger = new GraphLogger(nameof(this.HeartbeatShouldLogSuccess)); logger.DiagnosticLevel = TraceLevel.Error; var errorCount = 0; var observer = new Observer <LogEvent>( logger, onNext: @event => { Interlocked.Increment(ref errorCount); this.TestContext.WriteLine(formatter.Format(@event)); }, onError: @exception => { Assert.Fail(@exception.ToString()); }); var handler = new TestHandler(TimeSpan.FromSeconds(1), logger, args => { throw new Exception("Something went wrong!!!"); }); Thread.Sleep(TimeSpan.FromSeconds(4)); Assert.IsTrue(errorCount >= 2, $"errorCount >= 2 failed: errorCount = {errorCount}"); handler.Dispose(); }
/// <summary> /// add current responder to incident meeting as participant. /// </summary> private void TransferToIncidentMeeting() { Task.Run(async() => { try { var incidentMeetingCallId = statusData?.BotMeetingCallId; var responderStatusData = statusData?.GetResponder(responderId); if (incidentMeetingCallId != null && responderStatusData != null) { var addParticipantRequestData = new AddParticipantRequestData() { ObjectId = responderStatusData.ObjectId, ReplacesCallId = responderStatusData.NotificationCallId, }; await Bot.AddParticipantAsync(incidentMeetingCallId, addParticipantRequestData).ConfigureAwait(false); GraphLogger.Info("Finished to transfer to incident meeting. "); } else { GraphLogger.Warn( $"Tried to transfer to incident meeting but needed info are not valid. Meeting call-id: {incidentMeetingCallId}; status data: {responderStatusData}"); } } catch (Exception ex) { GraphLogger.Error(ex, "Failed to transfer to incident meeting."); throw; } }); }
public void HeartbeatShouldLogSuccess() { var formatter = new CommsLogEventFormatter(); var logger = new GraphLogger(nameof(this.HeartbeatShouldLogSuccess)); logger.DiagnosticLevel = TraceLevel.Verbose; var loggerCount = 0; var observer = new Observer <LogEvent>( logger, onNext: @event => { Interlocked.Increment(ref loggerCount); this.TestContext.WriteLine(formatter.Format(@event)); }, onError: @exception => { Assert.Fail(@exception.ToString()); }); var handler = new TestHandler(TimeSpan.FromSeconds(1), logger, args => { return(Task.CompletedTask); }); Thread.Sleep(TimeSpan.FromSeconds(4)); Assert.IsTrue(loggerCount >= 4, $"loggerCount >= 4 failed: loggerCount = {loggerCount}"); handler.Dispose(); }
/// <summary> /// Try to delete a call. /// </summary> /// <param name="callId">The call which will be deleted.</param> private void TryDeleteCall(string callId) { Task.Run(async() => { await Bot.TryDeleteCallAsync(callId).ConfigureAwait(false); GraphLogger.Info($"Try to delete call {callId}."); }); }
public Startup(IConfiguration configuration) { Configuration = configuration; StaticConfig = configuration; logger = new GraphLogger(typeof(Startup).Assembly.GetName().Name); observer = new SampleObserver(logger); DocumentDBRepository.Initialize(); }
void SetAnimFloatCreep(float val, float easing = 1) { #if DEBUG_ThirdPersonTakeCoverAgainstWall_CreepValue //Debug.LogWarning("SetAnimFloatCreep( "+val+" )\tTime: "+Time.time+"\tFixedTime: "+Time.fixedTime); GraphLogger.Log("SetAnimFloatCreep( " + val + " )", val, "Time:", updateTime, "FixedTime:", Time.fixedTime, "AnimMoveTimeDelta", animMoveTimeDelta); #endif val = (1 - easing) * anim.GetFloat("Creep") + easing * val; anim.SetFloat("Creep", val); }
/// <summary> /// Initializes a new instance of the <see cref="Startup"/> class. /// </summary> /// <param name="configuration">The configuration interface.</param> public Startup(IConfiguration configuration) { this.graphLogger = new GraphLogger(nameof(Startup)); // Log unhandled exceptions. AppDomain.CurrentDomain.UnhandledException += (_, e) => this.graphLogger.Error(e.ExceptionObject as Exception, $"Unhandled exception"); TaskScheduler.UnobservedTaskException += (_, e) => this.graphLogger.Error(e.Exception, "Unobserved task exception"); this.Configuration = configuration; }
public static async Task <Microsoft.Graph.OnlineMeeting> CreateOnlineMeetingAsync(string tenantId, string organizerId) { var name = typeof(Program).Assembly.GetName().Name; var logger = new GraphLogger(name); var onlineMeeting = new AppOnlineMeeting( new AuthenticationProvider(name, appId, appSecret, logger), graphUri); var meetingDetails = await onlineMeeting.CreateOnlineMeetingAsync(tenantId, organizerId, default(Guid)).ConfigureAwait(false); Console.WriteLine(meetingDetails.Id); Console.WriteLine(meetingDetails.ChatInfo.ThreadId); return(meetingDetails); }
void ExitCover() { #if DEBUG_ThirdPersonTakeCoverAgainstWall Debug.Log("ThirdPersonTakeCoverAgainstWall:ExitCover()"); #endif inCover = -1; anim.SetBool("InCover", false); tPUControl.enabled = true; tPCharacter.enabled = true; //rigid.isKinematic = false; // Re-enable physics #if DEBUG_ThirdPersonTakeCoverAgainstWall_CreepValue GraphLogger.PrintLog(); #endif }
void EnterCover(int pDir) { #if DEBUG_ThirdPersonTakeCoverAgainstWall Debug.Log("ThirdPersonTakeCoverAgainstWall:EnterCover()"); #endif inCover = pDir; tPUControl.enabled = false; tPCharacter.enabled = false; anim.SetBool("InCover", true); //rigid.isKinematic = true; // Disable physics from moving the character randomly // Position character right next to cover #if DEBUG_ThirdPersonTakeCoverAgainstWall_CreepValue GraphLogger.ClearLog(); #endif }
/// <summary> /// Subscribe to tone. /// </summary> private void SubscribeToTone() { Task.Run(async() => { try { await Call.SubscribeToToneAsync().ConfigureAwait(false); GraphLogger.Info("Started subscribing to tone."); } catch (Exception ex) { GraphLogger.Error(ex, "Failed to subscribe to tone. "); throw; } }); }
/// <summary> /// Play the notification prompt. /// </summary> private void PlayNotificationPrompt() { Task.Run(async() => { try { await Call.PlayPromptAsync(new List <MediaPrompt> { Bot.MediaMap[Bot.NotificationPromptName] }).ConfigureAwait(false); GraphLogger.Info("Started playing notification prompt"); } catch (Exception ex) { GraphLogger.Error(ex, "Failed to play notification prompt."); throw; } }); }
/// <summary> /// Called when recording status flip timer fires. /// </summary> /// <param name="source">The <see cref="ICall" /> source.</param> /// <param name="e">The <see cref="ElapsedEventArgs" /> instance containing the event data.</param> private void OnRecordingStatusFlip(ICall source, ElapsedEventArgs e) { _ = Task.Run(async() => { // TODO: consider rewriting the recording status checking var recordingStatus = new[] { RecordingStatus.Recording, RecordingStatus.NotRecording, RecordingStatus.Failed }; var recordingIndex = this.recordingStatusIndex + 1; if (recordingIndex >= recordingStatus.Length) { var recordedParticipantId = this.Call.Resource.IncomingContext.ObservedParticipantId; var recordedParticipant = this.Call.Participants[recordedParticipantId]; await recordedParticipant.DeleteAsync().ConfigureAwait(false); // Event - Recording has ended _eventPublisher.Publish("CallRecordingFlip", $"Call.Id: {Call.Id} ended"); return; } var newStatus = recordingStatus[recordingIndex]; try { // Event - Log the recording status var status = Enum.GetName(typeof(RecordingStatus), newStatus); _eventPublisher.Publish("CallRecordingFlip", $"Call.Id: {Call.Id} status changed to {status}"); // NOTE: if your implementation supports stopping the recording during the call, you can call the same method above with RecordingStatus.NotRecording await source .UpdateRecordingStatusAsync(newStatus) .ConfigureAwait(false); this.recordingStatusIndex = recordingIndex; } catch (Exception exc) { // e.g. bot joins via direct join - may not have the permissions GraphLogger.Error(exc, $"Failed to flip the recording status to {newStatus}"); // Event - Recording status exception - failed to update _eventPublisher.Publish("CallRecordingFlip", $"Failed to flip the recording status to {newStatus}"); } }).ForgetAndLogExceptionAsync(this.GraphLogger); }
/// <summary> /// Play the notification prompt. /// </summary> private void PlayNotificationPrompt() { Task.Run(async() => { try { var mediaName = endpointId == null ? Bot.BotIncomingPromptName : Bot.BotEndpointIncomingPromptName; await Call.PlayPromptAsync(new List <MediaPrompt> { Bot.MediaMap[mediaName] }).ConfigureAwait(false); GraphLogger.Info("Started playing notification prompt"); } catch (Exception ex) { GraphLogger.Error(ex, "Failed to play notification prompt."); throw; } }); }
public void HeartbeatShouldTrigger() { var logger = new GraphLogger(nameof(this.HeartbeatShouldTrigger)); var handlerCount = 0; var handler = new TestHandler(TimeSpan.FromSeconds(1), logger, args => { Interlocked.Increment(ref handlerCount); return(Task.CompletedTask); }); Thread.Sleep(TimeSpan.FromSeconds(3)); Assert.IsTrue(handlerCount >= 2, $"handlerCount >= 2 failed: handlerCount = {handlerCount}"); handler.Dispose(); handlerCount = 0; Thread.Sleep(TimeSpan.FromSeconds(1)); Assert.AreEqual(0, handlerCount); handler.Dispose(); }
/// <inheritdoc/> protected override void CallOnUpdated(ICall sender, ResourceEventArgs <Call> args) { statusData?.UpdateResponderNotificationStatus(responderId, sender.Resource.State); if (sender.Resource.State == CallState.Established) { var currentPromptTimes = Interlocked.Increment(ref promptTimes); if (currentPromptTimes == 1) { SubscribeToTone(); PlayNotificationPrompt(); } if (sender.Resource.ToneInfo?.Tone != null) { Tone tone = sender.Resource.ToneInfo.Tone.Value; GraphLogger.Info($"Tone {tone} received."); // handle different tones from responder switch (tone) { case Tone.Tone1: PlayTransferringPrompt(); TransferToIncidentMeeting(); break; default: PlayNotificationPrompt(); break; } sender.Resource.ToneInfo.Tone = null; } } }
/// <summary> /// Event fired when the call has been updated. /// </summary> /// <param name="sender">The call.</param> /// <param name="e">The event args containing call changes.</param> private async void CallOnUpdated(ICall sender, ResourceEventArgs <Call> e) { GraphLogger.Info($"Call status updated to {e.NewResource.State} - {e.NewResource.ResultInfo?.Message}"); // Event - Recording update e.g established/updated/start/ended _eventPublisher.Publish($"Call{e.NewResource.State}", $"Call.ID {Call.Id} Sender.Id {sender.Id} status updated to {e.NewResource.State} - {e.NewResource.ResultInfo?.Message}"); if (e.OldResource.State != e.NewResource.State && e.NewResource.State == CallState.Established) { if (!_isDisposed) { // Call is established. We should start receiving Audio, we can inform clients that we have started recording. OnRecordingStatusFlip(sender, null); } } if ((e.OldResource.State == CallState.Established) && (e.NewResource.State == CallState.Terminated)) { if (BotMediaStream != null) { var aQoE = BotMediaStream.GetAudioQualityOfExperienceData(); if (aQoE != null) { if (_settings.CaptureEvents) { await _capture?.Append(aQoE); } } await BotMediaStream.StopMedia(); } if (_settings.CaptureEvents) { await _capture?.Finalise(); } } }
public Startup(IConfiguration configuration) { Configuration = configuration; this.logger = new GraphLogger(typeof(Startup).Assembly.GetName().Name); }
public Startup(IConfiguration configuration) { this.Configuration = configuration; this.logger = new GraphLogger(typeof(Startup).Assembly.GetName().Name); this.observer = new SampleObserver(this.logger); }