public RemoteController(TVCommand displayCommand, TVCommand moveNextCommand, TVCommand movePreCommand) { this._displayCmd = displayCommand; this._moveNextCmd = moveNextCommand; this._movePreCmd = movePreCommand; }
public void CmdTVServerExec(TVCommand cmd, ContentType type, string arg) { print("cmd=" + cmd + "type=" + type + "arg" + arg); NetController ctrl = FindObjectOfType <NetController>(); if (ctrl != null) { if (cmd == TVCommand.StartGame) { ctrl.GameStart(type, arg); } else if (cmd == TVCommand.StopGame) { ctrl.GameStop(type, arg); } else if (cmd == TVCommand.ResetGame) { ctrl.GameReset(type, arg); } else if (cmd == TVCommand.BroadcastYes) { ctrl.ToggleBroadcast(true); } else if (cmd == TVCommand.BroadcastNo) { ctrl.ToggleBroadcast(false); } } }
void TogglBroadcast(bool b) { TVCommand cmd = TVCommand.BroadcastYes; if (!b) { cmd = TVCommand.BroadcastNo; } if (GameManager.inst.net.GetNetPlayer()) { GameManager.inst.net.GetNetPlayer().CmdTVServerExec(cmd, ContentType.None, ""); } }
static void Main(string[] args) { RemoteControl remote = new RemoteControl(); string userimput; remote.SetCommandForButton(1, new LightCommand(new Light())); remote.SetCommandForButton(2, new TVCommand(new TV())); remote.SetCommandForButton(3, new MusicCommand(new Music())); remote.SetCommandForButton(4, new TeapotCommand(new Teapot())); var teapotCommand = new TeapotCommand(new Teapot()); var tvCommand = new TVCommand(new TV()); var macroCommand = new MicroCommand(new List <ICommand> { teapotCommand, tvCommand }); remote.SetCommandForButton(5, macroCommand); do { Console.WriteLine("Выберите вариант ниже:"); Console.WriteLine(remote); Console.WriteLine("Your vibor: "); var input = Console.ReadLine(); int buttonId; int.TryParse(input, out buttonId); remote.PushButton(buttonId); remote.UndoButton(buttonId); // remote.DrawMenu(); // remote.PerformAction(); Console.WriteLine("\nAlso (y/n)?: "); userimput = Console.ReadLine(); } while (userimput == "y"); }
/// <summary> /// 此功能在miracast情况下使用,用于pc向tv发送命令,通知pc打开miracast接受软件 /// </summary> /// <param name="ipadress">ip地址</param> public static void sendCommand(string ipadress, TVCommand tvcommand) { Socket serverSocket = null; try { IPAddress ip = IPAddress.Parse(ipadress); serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); serverSocket.Connect(new IPEndPoint(ip, 12548)); byte[] result = new byte[1024]; log.InfoFormat("向TV {0} 发送命令: {1}", ipadress, JsonConvert.SerializeObject(tvcommand)); serverSocket.Send(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(tvcommand))); serverSocket.Close(); } catch (Exception e) { log.Error("向TV发送命令失败", e); //Console.WriteLine(e); } finally { serverSocket.Close(); } }
public void CmdTVServerExec(TVCommand cmd, ContentType type, string arg) { //TV端不需要实现 }