/// <summary> /// Send a code with a specific controller /// </summary> /// <param name="code"></param> /// <returns></returns> public static async Task <bool> Send(this IRCCCodes code, IRCCController controller) { if (controller == null) { throw new InvalidDataException("A controller must be defined"); } return(await controller.Send(code)); }
private static void Main(string[] args) { System.Console.Write("Host name ? "); string hostname = System.Console.ReadLine(); System.Console.Write("Pin Code ? "); string pin = System.Console.ReadLine(); if (string.IsNullOrWhiteSpace(pin)) { pin = "0000"; } IRCCController control = new IRCCController(hostname, pinCode: pin); IRCCCodesExtension.InitializeController(control); Task.Factory.StartNew(async() => { await control.Send(IRCCCodes.VolumeUp); await IRCCCodes.VolumeUp.Send(); await IRCCCodes.VolumeUp.Send(control); await control.VolumeUp(); await control.Send(IRCCCodes.VolumeDown); await IRCCCodes.VolumeDown.Send(); await IRCCCodes.VolumeDown.Send(control); await control.VolumeDown(); await control.Send(IRCCCodes.HDMI1); await control.Send(IRCCCodes.HDMI2); await control.Send(IRCCCodes.HDMI3); await control.Send(IRCCCodes.HDMI4); }); System.Console.WriteLine("Press enter to quit."); System.Console.ReadLine(); }
/// <summary> /// Initialize a new controller that will be used by the extensions /// </summary> /// <param name="hostName"></param> /// <param name="port"></param> /// <param name="pinCode"></param> public static void InitializeController(string hostName, int port = 80, string pinCode = "0000") { Controller = new IRCCController(hostName, port, pinCode); }
/// <summary> /// Initialize a new controller that will be used by the extensions once and for all /// </summary> /// <param name="controller"></param> public static void InitializeController(IRCCController controller) { Controller = controller ?? throw new ArgumentNullException(nameof(controller)); }
public static async Task <bool> VolumeUp(this IRCCController controller) { return(await controller.Send(IRCCCodes.VolumeUp)); }
public static async Task <bool> Stop(this IRCCController controller) { return(await controller.Send(IRCCCodes.Stop)); }
public static async Task <bool> Rewind(this IRCCController controller) { return(await controller.Send(IRCCCodes.Rewind)); }
public static async Task <bool> Play(this IRCCController controller) { return(await controller.Send(IRCCCodes.Play)); }
public static async Task <bool> Forward(this IRCCController controller) { return(await controller.Send(IRCCCodes.Forward)); }
public static async Task <bool> ChannelUp(this IRCCController controller) { return(await controller.Send(IRCCCodes.ChannelUp)); }