コード例 #1
0
        public void HandleInput(string json)
        {
            try
            {
                JObject data = JObject.Parse(json);

                switch ((string)data.GetValue("message_type"))
                {
                case "start_app":
                    TableApp app = TableAppManager.GetAppById((string)data.GetValue("app"));
                    Program.tableAppManager.LaunchApp(app);

                    CustomInterface customInterface = app.GetCustomInterface();
                    Send("{\"message_type\": \"show_interface\", \"app\": {\"name\": \"" + app.GetName().Replace("TableApp", "") + "\", \"id\": \"" + app.GetName() + "\"}, \"interface\": {\"items\": " + customInterface.toJson() + "}}");
                    break;

                case "input":
                    JObject input = JObject.Parse(data["input"].ToString());

                    Program.tableAppManager.GetCurrentApp()
                    .OnCustomInterfaceInput((string)input.GetValue("id"), (string)input.GetValue("value"));
                    break;
                }
            }
            catch (Exception e)
            {
                Program.LogFullLength(TAG, "Parsing received message failed! " + e.ToString());
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            DateTime startTime = DateTime.Now;

            //logName = startTime.ToString("dd.MM.yy H-mm-ss");
            //if (!System.IO.Directory.Exists("log/"))
            //    System.IO.Directory.CreateDirectory("logs/");

            LogFullLength(TAG, "System is now starting");

            //Extras
            programArgs = args;
            MUTED_TAG   = GetParameter("mute", "");
            random      = new Random();

            //Create TouchManager
            touchManager = new TouchManager(TableWidth, TableHeight);

            //Create Serial communication
            // /dev/ttyACM0
            serialController = new SerialController(GetParameter("com", "COM5"), GetParameterInt("baud", 57600), touchManager.OnRawInput);

            //Create Renderer
            string renderString = GetParameter("renderer", "fadecandy");

            CreateRenderer(renderString);

            //Launch Server
            int port = GetParameterInt("port", 25564);

            //communicationServer = new TcpCommunicationServer(port, false);
            //communicationServer.LaunchServer();

            //Launch WebSocket server
            webSocketServer = new WebSocketServer();

            //Create Appmanager
            tableAppManager = new TableAppManager();
            tableAppManager.LaunchApp(TableAppManager.GetAppById(GetParameter("app", new TableAppIdle().GetName())));


            //Open Serial communication
            serialController.Open();

            //Gamepads
            gamepadManager = new GamepadManager();

            LogFullLength(TAG, "System successfully started!");
            LogFullLength(TAG, "Time passed " + (DateTime.Now - startTime).TotalSeconds + " Seconds");

            // ConsoleInputManagment();
        }