コード例 #1
0
        /// <summary>
        /// listener for tcp light connections
        /// </summary>
        public void lightListener()
        {
            Console.WriteLine("Waiting for light connection...");
            while (true)
            {
                TcpClient tcpLightClient = tcpLightListener.AcceptTcpClient();

                int         index       = lightClients.Count;
                lightClient lightClient = new lightClient(this, tcpLightClient, index);
                lightClients.Add(lightClient);
            }
        }
コード例 #2
0
        private void closeConn()
        {
            bw.Close();
            br.Close();
            netStream.Close();
            client.Close();

            program.lightClients.RemoveAt(index);

            for (int i = index; i < program.lightClients.Count; i++)
            {
                lightClient c = program.lightClients[i];
                c.index = i;
            }
        }
コード例 #3
0
        /// <summary>
        /// recieves commandID and decides which key to press
        /// </summary>
        /// <param name="commandID"></param>
        public void commandDelegation(string commandID)
        {
            if (commandID == PLAYPAUSE) //play pause
            {
                const int VK_MEDIA_PLAY_PAUSE = 0xB3;

                PressKeys(VK_MEDIA_PLAY_PAUSE);
                WriteToScreen(commandID, "PP");
            }

            else if (commandID == VOLUP)
            {
                const int VK_VOLUME_UP = 0xAF;
                for (int i = 0; i < 5; i++)
                {
                    PressKeys(VK_VOLUME_UP);
                }
                WriteToScreen(commandID, "UP");
            }

            else if (commandID == VOLDOWN)
            {
                const int VK_VOLUME_DOWN = 0xAE;
                for (int i = 0; i < 5; i++)
                {
                    PressKeys(VK_VOLUME_DOWN);
                }
                WriteToScreen(commandID, "DOWN");
            }

            else if (commandID.Contains("#")) //placeholder
            {
                WriteToScreen(commandID, "COLOUR");

                //send color to light aplications
                for (int i = 0; i < lightClients.Count; i++)
                {
                    lightClient light = lightClients[i];
                    light.sendLightCode(commandID);
                }
            }

            else if (commandID == "new2") //placeholder
            {
            }
        }