Révision d752dab7 TestXamConnections/TestXamConnections.Android/Connection/InternConnectionService.cs

Voir les différences:

TestXamConnections/TestXamConnections.Android/Connection/InternConnectionService.cs
31 31
        /* La fonction connect dans le cas du connexion en interne
32 32
        *  Est en fait, la configuration de l'IntentReceiver
33 33
        */
34
        public Task Connect(Dictionary<string, string> param)
34
        public async Task Connect(Dictionary<string, string> param)
35 35
        {
36 36
            if (param.ContainsKey(ConnectionConstants.RECEIVABLE_INTENTS_KEY))
37 37
            {
......
43 43
                intents.ForEach(intent => intentFilter.AddAction(intent));
44 44

  
45 45
                appContext.RegisterReceiver(intentReceiver, intentFilter);
46
            } else
46
            }
47
            else
47 48
            {
48 49
                ConnectionFailedEvent.Invoke(this, null);
49 50
            }
50
            return null;
51
            return;
51 52
        }
52 53

  
53 54
        public Task<bool> SendCommand(string command)
......
64 65
        public InternConnectionService()
65 66
        {
66 67
            intentReceiver = new IntentReceiver();
67
            intentReceiver.OnInternDataReceived += OnInternDataReceived;
68
            intentReceiver.OnIntentReceived += IntentReceived;
68 69
            IntentFilter intentFilter = new IntentFilter();
69 70
            appContext = Application.Context.ApplicationContext;
70 71
        }
71 72

  
72
        private void OnInternDataReceived(object sender, string value)
73
        private void IntentReceived(object sender, Intent recIntent)
73 74
        {
74
            DataReceivedEvent.Invoke(this, new byte[] { 0x06 });
75
            switch (recIntent.Action)
76
            {
77
                case AgridentConstants.ACTION_AGRIDENT_SUCCESS:
78
                    string readData = recIntent.GetStringExtra(AgridentConstants.KEY_BARCODE_DATA);
79
                    DataReceivedEvent.Invoke(this, Encoding.ASCII.GetBytes(readData));
80
                    break;
81

  
82
                case AgridentConstants.ACTION_AGRIDENT_ERROR:
83
                    DataReceivedEvent.Invoke(this, Encoding.ASCII.GetBytes("ERROR"));
84
                    break;
85

  
86
                default:
87
                    break;
88
            }
75 89
        }
76 90

  
77 91
        public Task<bool> SendCommand(byte[] hexValues)

Formats disponibles : Unified diff