broke for a sec, back to working

fyi `dotnet restore` will say "no need :)", so you have to delete bin/ and obj/ when you need to dotnet restore
This commit is contained in:
Adam R. Grey 2021-09-01 01:16:29 -04:00
parent cc5efacccc
commit 47de14dca9
11 changed files with 153 additions and 90 deletions

View File

@ -14,6 +14,8 @@ namespace director
public string calendar_twitch { get; set; } public string calendar_twitch { get; set; }
public string calendar_other { get; set; } public string calendar_other { get; set; }
public TimeSpan preshowBufferTime { get; set; } public TimeSpan preshowBufferTime { get; set; }
public string show_template_yt_release { get; set; }
public string show_template_twitch_streams { get; set; }
public Dictionary<string, string> phase_handlers { get; set; } public Dictionary<string, string> phase_handlers { get; set; }
} }
} }

View File

@ -94,11 +94,18 @@ namespace director
} }
Console.WriteLine("calendars checked"); Console.WriteLine("calendars checked");
#if (DEBUG) #if (DEBUG)
for (int i = 0; i < 3; i++)
{
var psuedo = new Schedulable.Schedulable(); var psuedo = new Schedulable.Schedulable();
psuedo.Showtime = DateTime.Now + TimeSpan.FromSeconds(30); psuedo.Showtime = DateTime.Now + TimeSpan.FromSeconds(30);
var partiallyCopiable = scratch.agenda?.FirstOrDefault(s => s.ScedulableType == Schedulable.ScedulableType.YTRelease);
psuedo.Occurrence = partiallyCopiable.Occurrence;
psuedo.Occurrence.OccurrenceStart = psuedo.Showtime;
psuedo.Occurrence.OccurrenceEnd = psuedo.Showtime;
psuedo.ScedulableType = Schedulable.ScedulableType.YTRelease; psuedo.ScedulableType = Schedulable.ScedulableType.YTRelease;
workQueue.Enqueue(psuedo); workQueue.Enqueue(psuedo);
_signal.Set(); _signal.Set();
}
#endif #endif
} }
@ -150,32 +157,25 @@ namespace director
Task.WaitAll(Task.Delay(napLength)); Task.WaitAll(Task.Delay(napLength));
} }
try
{
switch (todo.ScedulableType) switch (todo.ScedulableType)
{ {
case Schedulable.ScedulableType.TwitchStream: case Schedulable.ScedulableType.TwitchStream:
try new TwitchStreamHandler().Handle(todo.Occurrence);
{
TwitchStreamHandler.Handle(todo.Occurrence);
}
catch(Exception e)
{
Log.Panic($"error in twitch stream handler! Panicking!\n{JsonConvert.SerializeObject(e)}");
}
break; break;
case Schedulable.ScedulableType.YTRelease: case Schedulable.ScedulableType.YTRelease:
try new YoutubeHandler().Handle(todo.Occurrence);
{ break;
YoutubeHandler.Handle(todo.Occurrence); default:
throw new NotImplementedException($"unknown schedulable type!\n{JsonConvert.SerializeObject(todo)}");
}
} }
catch (Exception e) catch (Exception e)
{ {
Log.Panic($"error in youtube release handler! Panicking!\n{JsonConvert.SerializeObject(e)}"); Log.Panic($"error in show handler! Panicking!\n{JsonConvert.SerializeObject(e)}");
} }
break; break;
default:
Log.Panic($"unknown schedulable type! abandoning!");
break;
}
} }
} }
} }

View File

@ -7,5 +7,7 @@
"calendar_youtube": "calendars/1wingedangle/youtube-channel_shared_by_adam", "calendar_youtube": "calendars/1wingedangle/youtube-channel_shared_by_adam",
"calendar_twitch": "calendars/1wingedangle/twitch-channel_shared_by_adam", "calendar_twitch": "calendars/1wingedangle/twitch-channel_shared_by_adam",
"calendar_other": "calendars/1wingedangle/other_shared_by_adam", "calendar_other": "calendars/1wingedangle/other_shared_by_adam",
"preshowBufferTime": "04:00:00" "preshowBufferTime": "04:00:00",
"show_template_yt_release": "./yt release/config.json",
"show_template_twitch_streams": "./twitch stream configs/"
} }

View File

@ -7,7 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="silvermeddlists.franz" Version="0.0.2" /> <PackageReference Include="silvermeddlists.franz" Version="0.0.4" />
<PackageReference Include="WebDav.Client" Version="2.7.0" /> <PackageReference Include="WebDav.Client" Version="2.7.0" />
<PackageReference Include="Ical.Net" Version="4.2.0" /> <PackageReference Include="Ical.Net" Version="4.2.0" />
</ItemGroup> </ItemGroup>

37
schedulable/Show.cs Normal file
View File

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
namespace Schedulable.Show
{
public class Show
{
public PreshowTaskList PreShow { get; set; }
public TaskList PostShow { get; set; }
#region components
public class TaskList
{
public IEnumerable<Checklistable> Manual { get; set; }
public IEnumerable<string> Commands { get; set; }
}
public class PreshowTaskList : TaskList
{
public IEnumerable<string> AgentsNeeded { get; set; }
public IEnumerable<string> Checks { get; set; }
}
public class Checklistable
{
//for humans
public string Label { get; set; }
public IEnumerable<Checklistable> Items { get; set; } //if no items, just throw up a checkbox
}
#endregion
}
public class TwitchStream : Show
{
public string TwitchTitle { get; set; }
public string TwitchCategory { get; set; }
}
public class YoutubeRelease : Show { }
}

View File

@ -1,32 +0,0 @@
using System.Collections.Generic;
namespace Schedulable.Show
{
public class Show
{
public string Name { get; set; }
public Preparation Preperation { get; set; }
public IEnumerable<Phase> Procedure { get; set; }
public TaskList Postshow { get; set; }
}
public class Phase
{
public string Name { get; set; }
}
public class TaskList
{
public IEnumerable<Checklistable> Manual { get; set; }
public IEnumerable<string> Commands { get; set; }
}
public class Preparation : TaskList
{
public IEnumerable<string> AgentsNeeded { get; set; }
public IEnumerable<string> Checks { get; set; }
}
public class Checklistable
{
//for humans
public string Label { get; set; }
public IEnumerable<Checklistable> Items { get; set; } //if no items, just throw up a checkbox
}
}

View File

@ -1,7 +0,0 @@
namespace Schedulable.Show
{
public class TwitchStream : Show
{
public string TwitchCategory { get; set; }
}
}

View File

@ -1,7 +0,0 @@
namespace Schedulable.Show
{
public class YoutubeRelease : Show
{
//do I even need anything?
}
}

View File

@ -0,0 +1,10 @@
using System;
using director;
namespace ShowHandlers
{
public abstract class ShowHandler
{
public abstract void Handle(iCalHoopJumping.CalendarOccurrence evt);
}
}

View File

@ -3,9 +3,9 @@ using director;
namespace ShowHandlers namespace ShowHandlers
{ {
public class TwitchStreamHandler public class TwitchStreamHandler : ShowHandler
{ {
public static void Handle(iCalHoopJumping.CalendarOccurrence evt) public override void Handle(iCalHoopJumping.CalendarOccurrence evt)
{ {
Console.WriteLine("I am a twitch stream handler, it falls to me to..."); Console.WriteLine("I am a twitch stream handler, it falls to me to...");
Console.WriteLine(" H A N D L E "); Console.WriteLine(" H A N D L E ");

View File

@ -1,15 +1,73 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using director; using director;
using franz;
using Newtonsoft.Json;
using Schedulable.Show;
namespace ShowHandlers namespace ShowHandlers
{ {
public class YoutubeHandler public class YoutubeHandler : ShowHandler
{ {
public static void Handle(iCalHoopJumping.CalendarOccurrence evt) private YoutubeRelease config;
private List<string> agentsPresent = new List<string>();
private bool essentialChecksPassed = false;
private bool allChecksPassed = false;
private readonly AutoResetEvent checkSignal = new AutoResetEvent(false);
public override void Handle(iCalHoopJumping.CalendarOccurrence evt)
{ {
Console.WriteLine("I am a YT handler, it falls to me to..."); config = JsonConvert.DeserializeObject<YoutubeRelease>(Program.conf.show_template_yt_release);
Console.WriteLine(" H A N D L E "); config.PreShow.AgentsNeeded = config.PreShow.AgentsNeeded.Select(s => s.ToLower());
Console.WriteLine($"current time is {DateTime.Now}"); Telefranz.Instance.addHandler<silver_messages.global.report>(agentReports);
Task.Run(() => PreShow(evt));
if(evt.OccurrenceStart > DateTime.Now)
{
Task.WaitAll(Task.Delay(evt.OccurrenceStart - DateTime.Now));
}
PostShow(evt);
}
~YoutubeHandler()
{
Telefranz.Instance.removeHandler<silver_messages.global.report>(agentReports);
}
protected void PreShow(iCalHoopJumping.CalendarOccurrence evt)
{
Console.WriteLine($"it's the pre-show, showtime at: {evt.OccurrenceStart}");
agentsPresent.Clear();
essentialChecksPassed = false;
allChecksPassed = false;
Task.WaitAny(
Task.Delay(10)
);
Telefranz.Instance.ProduceMessage(new silver_messages.global.sound_off());
while(agentsPresent.Where(ap => !config.PreShow.AgentsNeeded.Contains(ap))?.Count() > 0)
{
checkSignal.WaitOne(TimeSpan.FromSeconds(45));
}
// //await sound offs for some timeout
// config.PreShow.AgentsNeeded;
// //once that's ok, await checks
// config.PreShow.Checks;
// //once that's ok, await first command, then start running them
// config.PreShow.Commands;
}
protected void agentReports(silver_messages.global.report r)
{
if(config.PreShow.AgentsNeeded?.FirstOrDefault(an => an.ToLower() == r.name.ToLower()) != null)
{
lock(agentsPresent)
{
agentsPresent.Add(r.name.ToLower());
checkSignal.Set();
}
}
}
protected void PostShow(iCalHoopJumping.CalendarOccurrence evt)
{
Console.WriteLine("can't do this bit without understanding when a show ends, sooo.");
} }
} }
} }