コード例 #1
0
        public SparListener(string key = "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
        {
            //_key = key;
            _ipdaemon = new SparIpdaemon(key)
            {
                LocalPort = SPAR_PORT_2
            };
            _ipdaemon.OnAesDataIn += (o, e, msg) => {
                if (msg.Contains("Reboot"))
                {
                    /*if (Rebooted != null)
                     *  Rebooted(getSparIP(e.ConnectionId));*/
                    Rebooted?.Invoke(getSparIP(e.ConnectionId));
                    return;
                }

                /*if (CardScanned != null)
                 *  CardScanned(getSparIP(e.ConnectionId), Util.GetCardData(msg));*/
                CardScanned?.Invoke(getSparIP(e.ConnectionId), Util.GetCardData(msg));
            };
            _ipdaemon.OnError += (o, e) => {
                /*if (Error != null)
                 *  Error(e.Description);*/
                Error?.Invoke(e.Description);
            };
            _ipdaemon.OnConnectionRequest += (o, e) => {
                e.Accept = true;
            };

            /*_ipdaemon.OnConnected += (o, e) =>
             * {
             *  Console.WriteLine("Spar listener is connected");
             * };
             * _ipdaemon.OnReadyToSend += (o, e) =>
             * {
             *  Console.WriteLine("Ready to send");
             * };*/
            //_ipdaemon.OnReadyToSend += (o, e) =>
            //{
            //    //_ipdaemon.Connections[e.ConnectionId].RemoteHost;
            //    if (Ready != null)
            //        Ready(_ipdaemon.Connections[e.ConnectionId].RemoteHost);
            //};
        }
コード例 #2
0
 public static void InvokeScanned(string uid)
 {
     CardScanned?.Invoke(uid);
 }