Example #1
0
        public void Initialize(Configuration configuration)
        {
            LogType = configuration.LogType;
            int port = 0;

            if (LogType == LogType.CHAINSAW)
            {
                port      = configuration.PortChainsaw;
                Converter = IoC.Get <ChainsawToLogConverter>();
            }
            else if (LogType == LogType.LOGCAT)
            {
                port      = configuration.PortLogcat;
                Converter = IoC.Get <LogcatToLogConverter>();
            }
            if (Client != null)
            {
                Client.Close();
            }

            bool isPortAlreadyInUse = (from p
                                       in IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners()
                                       where p.Port == port
                                       select p).Count() == 1;

            if (isPortAlreadyInUse)
            {
                throw new LoginatorException("Port " + port + " is already in use.");
            }

            Client = new UdpClient(port);
            UdpState state = new UdpState(Client, new IPEndPoint(IPAddress.Any, 0));

            Client.BeginReceive(new AsyncCallback(DataReceived), state);
        }
Example #2
0
        public void Initialize(Configuration configuration)
        {
            LogType = configuration.LogType;
            int port = 0;
            if (LogType == LogType.CHAINSAW) {
                port = configuration.PortChainsaw;
                Converter = IoC.Get<ChainsawToLogConverter>();
            } else if (LogType == LogType.LOGCAT) {
                port = configuration.PortLogcat;
                Converter = IoC.Get<LogcatToLogConverter>();
            }
            if (Client != null) {
                Client.Close();
            }

            bool isPortAlreadyInUse = (from p
                                 in IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners()
                                 where p.Port == port
                                 select p).Count() == 1;

            if (isPortAlreadyInUse) {
                throw new LoginatorException("Port " + port + " is already in use.");
            }

            Client = new UdpClient(port);
            UdpState state = new UdpState(Client, new IPEndPoint(IPAddress.Any, 0));
            Client.BeginReceive(new AsyncCallback(DataReceived), state);
        }