public static void StartListening(Action <SystemTracks> funcThatWantTheData)
        {
            IConnection connection = RabbitMQConnection.getConnection();

            trackDataChannel = connection.CreateModel();

            trackDataChannel.ExchangeDeclare(exchange: "LucidTrackData", type: ExchangeType.Fanout);

            trackDataChannel.QueueDeclare(queue: "track",
                                          durable: false,
                                          exclusive: false,
                                          autoDelete: true,
                                          arguments: null);

            trackDataChannel.QueueBind(queue: "track", exchange: "LucidTrackData", routingKey: "");

            var consumer = new EventingBasicConsumer(trackDataChannel);

            consumer.Received += (model, ea) =>
            {
                byte[]       body      = ea.Body;
                SystemTracks trackData = JsonConvert.DeserializeObject <SystemTracks>(Encoding.UTF8.GetString(body));
                funcThatWantTheData(trackData);
            };

            trackDataChannel.BasicConsume(queue: "track",
                                          autoAck: true,
                                          consumer: consumer);
        }
Beispiel #2
0
        public static void onReceiveTracks(SystemTracks trackData)
        {
            double heading = BeamsBuffer.Heading;

            //retreive the actual beams from the BeamBuffer
            byte[][] beamArray = BeamsBuffer.getBeamsAndFlush();

            if (beamArray == null)
            {
                return;
            }

            foreach (var track in trackData.systemTracks)
            {
                TrackBeamData trackBeamData = CalcBeams(track.trackID, heading, track.relativeBearing, beamArray);
                TrackBeamDataSender.sendTrackBeamData(trackBeamData);
            }
        }