private void textKeyboard(object sender, object e)
        {
            Keyboard = arduino.analogRead("A1");
            Debug.WriteLine(Keyboard);

            if (850 < Keyboard && Keyboard < 900)
            {
                _serviceSocket = new ServiceSocket("192.168.0.12");
                String task = "CONNECT";
                _serviceSocket.setTask(task);
                _serviceSocket.send();

                Debug.WriteLine("S5");
            }
            else if (700 < Keyboard && Keyboard < 800)
            {
                Debug.WriteLine("S4");
            }
            else if (650 < Keyboard && Keyboard < 700)
            {
                Debug.WriteLine("S3");
            }
            else if (600 < Keyboard && Keyboard < 650)
            {
                Debug.WriteLine("S2");
            }
            else if (550 < Keyboard && Keyboard < 600)
            {
                Debug.WriteLine("S1");
            }
            else
            {
                Debug.WriteLine("Default");
            }
        }
示例#2
0
        private void Init()
        {
            if (Started)
            {
                throw new InvalidOperationException("Service is already started");
            }
            Started = true;

            if (Configuration.EndPoints.Count == 0)
            {
                return;
            }

            Configuration.MakeReadonly();

            var endPoints = Configuration.EndPoints;

            m_SvcSockets = new ServiceSocket[endPoints.Count];
            for (int i = 0; i < endPoints.Count; i++)
            {
                var endPoint = endPoints[i];
                var socket   = CreateSocket(endPoint);
                m_SvcSockets[i] = new ServiceSocket(socket, endPoint);
            }

            TaskCompletionSourcePool = CreatePool(
                TcpServicePoolType.Cache,
                Configuration.TaskCompletionSourcePoolCount,
                () => new TaskCompletionSource <bool>());

            BufferlessSendAsyncEventArgsPool = CreatePool(
                Configuration.SendEventArgsPoolType,
                Configuration.SendEventArgsPoolCount,
                () => new SocketAsyncEventArgs());

            SendAsyncEventArgsPool = CreateSAEABufferPool(
                Configuration.SendBufferPoolCount,
                Configuration.SendBufferSize,
                Configuration.SendBufferPoolType);

            ReceiveAsyncEventArgsPool = CreateSAEABufferPool(
                Configuration.ReceiveBufferPoolCount,
                Configuration.ReceiveBufferSize,
                Configuration.ReceiveBufferPoolType);
        }
示例#3
0
        private void AcceptLoop(ServiceSocket serviceSocket)
        {
            var socket   = serviceSocket.Socket;
            var endPoint = serviceSocket.ServiceEndPoint;

            while (true)
            {
                try
                {
                    var client = socket.Accept();
                    HandleClientSocket(endPoint, client, client.RemoteEndPoint as IPEndPoint);
                }
                catch (SocketException)
                {
                    Dispose();
                    break;
                }
            }
        }
示例#4
0
 public ServiceTriggerAction()
 {
     _serviceSocket = new ServiceSocket(_hubConnection);
 }