Hello
I have my JoingMeetingViewModel
private string? elapsedTimeString;
private readonly Stopwatch? stopwatch = new();
private Timer? meetingTimer;
private Timer? breakTimeTimer;
private MeetingData? data;
private Timer? apiRequestDataTimer;
[RelayCommand]
async Task EntryCompleted() {
await VerifyAddressAsync(appService);
}
public async Task InitializeApiPolling() {
StartMeetingApiPolling();
await UpdateMeetingData();
}
private void StartMeetingApiPolling() {
apiRequestDataTimer = new Timer(
async state => await GetMeeetingData(),
null,
TimeSpan.Zero,
TimeSpan.FromSeconds(30)
);
}
private void StartBreakTimeTimer() {
breakTimeTimer = new Timer(
state => ShowAlert(new BreakTimePopUp()),
null,
TimeSpan.FromSeconds(30),
Timeout.InfiniteTimeSpan);
}
private void StartMeetingTimer() {
stopwatch!.Start();
meetingTimer = new Timer(state => UpdateElapsedTime(),
null,
TimeSpan.Zero,
TimeSpan.FromSeconds(1));
}
private void UpdateElapsedTime() {
TimeSpan elapsed = stopwatch!.Elapsed;
ElapsedTimeString = $"{elapsed.Hours:D2}:{elapsed.Minutes:D2}:{elapsed.Seconds:D2}";
}
private async Task UpdateMeetingData() {
if(data == null) {
data = (MeetingData?)await meetingService.GetMeetingData(RoomName, Constants.DAILY_AUTH_TOKEN);
await GetMeeetingData();
}
; // Trigger data processing
}
private async Task VerifyAddressAsync(IAppService appService) {
if(Text is not null && Text!.Contains("demy-ia")) {
GotoSite();
} else {
await appService.DisplayAlert("Error", "Please paste a valid meeting link", "OK");
}
}
private async void GotoSite() {
if(!string.IsNullOrEmpty(Text)) {
IsWebViewVisible = true;
if(IsWebViewVisible) {
ToolbarVisibility = !ToolbarVisibility;
MeetingSearchVibiility = !MeetingSearchVibiility;
appShell.FlyoutWidth = 0;
StartBreakTimeTimer();
await InitializeApiPolling();
StartMeetingTimer();
}
}
}
private async Task GetMeeetingData() {
if(data != null) {
var meetingData = data;
bool isOngoing = meetingData!.data[0].ongoing;
if(isOngoing is false) {
await appService.DisplayAlert(Title, "you are in the lobby", "OK");
} else if(isOngoing is true) {
await appService.DisplayAlert(Title, "you are in the meeting", "OK");
}
}
}
}
Ok so the way this is supposed to work is: When I enter a meeting, I am waiting in the lobby, therefore ongoing
is false.
and when I enter the meeting the ongoing
changes to true
{
"total_count": 45,
"data": [{
"id": "5fd28059-c9a3-4d25-af75-543189b851c1",
"room": "Programming101",
"start_time": 1708179804,
"duration": 90,
"ongoing": true,
"max_participants": 1,
"participants": [{
"user_id": null,
"participant_id": "917dacbb-504a-4e7c-afca-331b5a266f92",
"user_name": "eduardo",
"join_time": 1708179804,
"duration": 90
but for some reason when my
StartMeetingApiPolling()
calls again, the value dosen change and I get an exception
also the
private void StartMeetingTimer() {
stopwatch!.Start();
meetingTimer = new Timer(state => UpdateElapsedTime(),
null,
TimeSpan.Zero,
TimeSpan.FromSeconds(1));
}
for some reason at certain point in the app, it will skip a number, for example from 21 to 23, or 30 to 32.
Demo
https://github.com/eduardoagr/DemyAI
Video
I want to start the
StartBreakTimeTimer and StartMeetingTimer, when I am inside the room
and to destroy the polling thread when I enter the meeting.