Пример #1
0
        public void zmqBeginListen(object data)
        {
            Subscriber = new SubscriberSocket();

            ZMQAddress = "tcp://" + Ip + ":3000";
            Console.WriteLine("I: Connecting to {0}...", ZMQAddress);
            Subscriber.Connect(ZMQAddress);

            Subscriber.Subscribe("telemetry");

            var poller = new NetMQPoller {
                Subscriber
            };

            Subscriber.ReceiveReady += (s, a) =>
            {
                if (NetworkClass.Paused)
                {
                    return;
                }
                NetworkNode.NodeZMQSeen();
                byte[] reply = a.Socket.ReceiveFrameBytes();

                int i = 10;
                while (i < reply.Length && reply[i] != 0xd5)
                {
                    i++;
                }
                NetworkClass.ProcessZMQTelemetryFrame(reply.Skip(i).ToArray(), NetworkNode.NodeNameShort);
            };
            poller.Run();
        }
Пример #2
0
        //Called when a new node is detected on the network
        public static void NewNodeDetected(rPodNetworkNode node)
        {
            ZMQTelemetryProcessor processor = new ZMQTelemetryProcessor();

            processor.NetworkNode = node;
            processor.Ip          = node.IP;
            Thread newThread = new Thread(processor.zmqBeginListen);

            node.TelemetryProcessor = processor;
            node.NodeZMQSeen();
            runningThreads.Add(newThread);
            newThread.Start();
        }
Пример #3
0
        public void zmqBeginListen(object data)
        {
            Subscriber = new SubscriberSocket();

            ZMQAddress = "tcp://" + Ip + ":3000";
            Console.WriteLine("I: Connecting to {0}...", ZMQAddress);
            Subscriber.Connect(ZMQAddress);

            Subscriber.Subscribe("telemetry");

            var poller = new NetMQPoller {
                Subscriber
            };

            Subscriber.ReceiveReady += (s, a) =>
            {
                if (rPodNetworking.Paused)
                {
                    return;
                }
                NetworkNode.NodeZMQSeen();
                byte[] reply = a.Socket.ReceiveFrameBytes();

                int i = 10;
                while (i < reply.Length && reply[i] != 0xd5)
                {
                    i++;
                }
                rPodNetworking.ProcessZMQTelemetryFrame(reply.Skip(i).ToArray(), NetworkNode.NodeNameShort);
            };
            try
            {
                poller.Run();
            }
            catch { Console.WriteLine("Problem with subscriber running, possibly a node that changed or went offline (?)"); }
        }