1

Estou precisando coletar informações de uso da internet no iphone , o código em c# abaixo que estou utilizando só me retorna valores zerados.

estou utilizando a classe certa ?

tem alguma referência que preciso adicionar no xamarin ?

no mono me aparece 3 tipos de classes , concidentemente a interface "MacOsIPv4InterfaceStatistics" retorna fixo sempre o valor 0.

https://github.com/mono/mono/blob/master/mcs/class/System/System.Net.NetworkInformation/IPv4InterfaceStatistics.cs

  1. Win32IPv4InterfaceStatistics
  2. LinuxIPv4InterfaceStatistics
  3. MacOsIPv4InterfaceStatistics

    using System;
    using System.Net;
    using System.Net.NetworkInformation;
    using System.Runtime.InteropServices;
    using System.Threading;
    using MonoTouch.ObjCRuntime;
    

    namespace Taximetro { public delegate void Update();

    public static class ControleUso
    {
        public static long controller;
    
        public static long BytesReceivedWiFi;
        public static long BytesSentWiFi;
    
        public static long BytesReceived3G;
        public static long BytesSent3G;
    
        public static Update UpdateMethod;
    
        public static void DoWork()
        {    
            foreach (var netint in NetworkInterface.GetAllNetworkInterfaces()) {
                var stats = netint.GetIPv4Statistics ();
    
                //WiFi
                //if (netint.Name.StartsWith ("en")) {
                    BytesReceivedWiFi += stats.BytesReceived;
                    BytesSentWiFi += stats.BytesSent;
                //}
    
                //3G
                if (netint.Name.StartsWith ("pdp_ip")) {
                    BytesReceived3G += stats.BytesReceived;
                    BytesSent3G += stats.BytesSent;
                }
            }
            controller++;
            if (UpdateMethod != null) {
                UpdateMethod ();
            }
            Thread.Sleep (1000);
        }
    }
    

    }

2

0

Você deve fazer log-in para responder a esta pergunta.

Pesquise outras perguntas com a tag .