separate handlers

This commit is contained in:
Adam R. Grey 2021-08-21 00:55:33 -04:00
parent f7478e1ae7
commit ea06956780
3 changed files with 33 additions and 16 deletions

View File

@ -127,7 +127,7 @@ namespace director
if (!workQueue.TryDequeue(out todo)) { continue; } if (!workQueue.TryDequeue(out todo)) { continue; }
Console.WriteLine($"threadwork consumes! showtime at {todo.Showtime}; wake me at {todo.Showtime - conf.preshowBufferTime}"); Console.WriteLine($"threadwork consumes! showtime at {todo.Showtime}; napping until {todo.Showtime - conf.preshowBufferTime}");
switch(todo.ScedulableType) switch(todo.ScedulableType)
{ {
case Schedulable.ScedulableType.TwitchStream: case Schedulable.ScedulableType.TwitchStream:
@ -137,25 +137,31 @@ namespace director
Console.WriteLine("it's a yt release"); Console.WriteLine("it's a yt release");
break; break;
} }
//Task.WaitAll(Task.Delay((todo.Showtime - conf.preshowBufferTime) - DateTime.Now)); Task.WaitAll(Task.Delay((todo.Showtime - conf.preshowBufferTime) - DateTime.Now));
Console.WriteLine("time to prep!"); Console.WriteLine("time to prep!");
switch (todo.ScedulableType) switch (todo.ScedulableType)
{ {
case Schedulable.ScedulableType.TwitchStream: case Schedulable.ScedulableType.TwitchStream:
try try
{ {
var handler = new TwitchStreamHandler(todo.Occurrence); TwitchStreamHandler.Handle(todo.Occurrence);
handler.Handle();
} }
catch(Exception e) catch(Exception e)
{ {
Log.Panic($"error in twitch stream handler! Panicking!\n{JsonConvert.SerializeObject(e)}"); Log.Panic($"error in twitch stream handler! Panicking!\n{JsonConvert.SerializeObject(e)}");
} }
break; break;
// case Schedulable.ScedulableType.YTRelease: case Schedulable.ScedulableType.YTRelease:
// break; try
{
YoutubeHandler.Handle(todo.Occurrence);
}
catch(Exception e)
{
Log.Panic($"error in youtube release handler! Panicking!\n{JsonConvert.SerializeObject(e)}");
}
break;
default: default:
Log.Panic($"unknown schedulable type! abandoning!"); Log.Panic($"unknown schedulable type! abandoning!");
break; break;

View File

@ -1,19 +1,15 @@
using System;
using director; using director;
using Ical.Net.CalendarComponents;
namespace ShowHandlers namespace ShowHandlers
{ {
public class TwitchStreamHandler public class TwitchStreamHandler
{ {
public TwitchStreamHandler(iCalHoopJumping.CalendarOccurrence evt) public static void Handle(iCalHoopJumping.CalendarOccurrence evt)
{
Event = evt;
}
public iCalHoopJumping.CalendarOccurrence Event { get; }
public void Handle()
{ {
Console.WriteLine("I am a twitch stream handler, it falls to me to...");
Console.WriteLine(" H A N D L E ");
Console.WriteLine($"current time is {DateTime.Now}");
} }
} }
} }

View File

@ -0,0 +1,15 @@
using System;
using director;
namespace ShowHandlers
{
public class YoutubeHandler
{
public static void Handle(iCalHoopJumping.CalendarOccurrence evt)
{
Console.WriteLine("I am a YT handler, it falls to me to...");
Console.WriteLine(" H A N D L E ");
Console.WriteLine($"current time is {DateTime.Now}");
}
}
}