Example #1
0
        public NabbixAgent(ItemRegistry registry, string address, int port, bool startImmediately = true)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            _registry = registry;
            _address  = address == null
                ? IPAddress.Any
                : IPAddress.Parse(address);
            _port = port;

            if (startImmediately)
            {
                Start();
            }
        }
Example #2
0
        internal static void Run(TcpClient client, ItemRegistry registry)
        {
            Log.Debug("Run... .");

            var stream = client.GetStream();

            do
            {
                Log.Debug("Request recieving...");
                string request = GetRequest(stream);
                Log.DebugFormat("Request received: {0}", request);

                string response = registry.GetItemValue(request);
                Log.DebugFormat("Response: {0}", response);
                SendResponse(stream, response);
            } while (stream.DataAvailable);

            Log.Debug("Run. Ended.");
        }