The body for an EDDN request
Esempio n. 1
0
        private void sendOutfittingInformation()
        {
            if (EDDI.Instance.CurrentStation != null && EDDI.Instance.CurrentStation.outfitting != null)
            {
                List <string> eddnModules = new List <string>();
                foreach (Module module in EDDI.Instance.CurrentStation.outfitting)
                {
                    if ((!ModuleDefinitions.IsPP(module)) &&
                        (module.EDName.StartsWith("Int_") || module.EDName.StartsWith("Hpt_") || module.EDName.Contains("_Armour_")) &&
                        (!(module.EDName == "Int_PlanetApproachSuite")))
                    {
                        eddnModules.Add(module.EDName);
                    }
                }

                // Only send the message if we have modules
                if (eddnModules.Count > 0)
                {
                    IDictionary <string, object> data = new Dictionary <string, object>();
                    data.Add("timestamp", DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
                    data.Add("systemName", EDDI.Instance.CurrentStation.systemname);
                    data.Add("stationName", EDDI.Instance.CurrentStation.name);
                    data.Add("modules", eddnModules);

                    EDDNBody body = new EDDNBody();
                    body.header    = generateHeader();
                    body.schemaRef = "https://eddn.edcd.io/schemas/outfitting/2" + (EDDI.Instance.inBeta ? "/test" : "");
                    body.message   = data;

                    sendMessage(body);
                }
            }
        }
Esempio n. 2
0
        private void sendShipyardInformation()
        {
            if (EDDI.Instance.CurrentStation != null && EDDI.Instance.CurrentStation.shipyard != null)
            {
                List <string> eddnShips = new List <string>();
                foreach (Ship ship in EDDI.Instance.CurrentStation.shipyard)
                {
                    eddnShips.Add(ship.EDName);
                }

                // Only send the message if we have ships
                if (eddnShips.Count > 0)
                {
                    IDictionary <string, object> data = new Dictionary <string, object>();
                    data.Add("timestamp", DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
                    data.Add("systemName", EDDI.Instance.CurrentStation.systemname);
                    data.Add("stationName", EDDI.Instance.CurrentStation.name);
                    data.Add("ships", eddnShips);

                    EDDNBody body = new EDDNBody();
                    body.header    = generateHeader();
                    body.schemaRef = "https://eddn.edcd.io/schemas/shipyard/2" + (EDDI.Instance.inBeta ? "/test" : "");
                    body.message   = data;

                    sendMessage(body);
                }
            }
        }
Esempio n. 3
0
        private void sendShipyardInformation()
        {
            if (EDDI.Instance.CurrentStation != null && EDDI.Instance.CurrentStation.shipyard != null)
            {
                List <string> eddnShips = new List <string>();
                foreach (Ship ship in EDDI.Instance.CurrentStation.shipyard)
                {
                    eddnShips.Add(ship.EDName);
                }

                // Only send the message if we have ships
                if (eddnShips.Count > 0)
                {
                    IDictionary <string, object> data = new Dictionary <string, object>
                    {
                        { "timestamp", DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ") },
                        { "systemName", systemName },
                        { "stationName", stationName },
                        { "marketId", marketId },
                        { "ships", eddnShips }
                    };

                    EDDNBody body = new EDDNBody
                    {
                        header    = generateHeader(),
                        schemaRef = "https://eddn.edcd.io/schemas/shipyard/2" + (EDDI.Instance.ShouldUseTestEndpoints() ? "/test" : ""),
                        message   = data
                    };

                    sendMessage(body);
                }
            }
        }
Esempio n. 4
0
        private static void sendMessage(EDDNBody body)
        {
            var client  = new RestClient("https://eddn.edcd.io:4430/");
            var request = new RestRequest("upload/", Method.POST);

            request.AddParameter("application/json", JsonConvert.SerializeObject(body), ParameterType.RequestBody);

            Logging.Debug("Sending " + JsonConvert.SerializeObject(body));

            Thread thread = new Thread(() =>
            {
                try
                {
                    IRestResponse response = client.Execute(request);
                    var content            = response.Content; // raw content as string
                    Logging.Debug("Response content is " + content);
                }
                catch (ThreadAbortException)
                {
                    Logging.Debug("Thread aborted");
                }
                catch (Exception ex)
                {
                    Logging.Warn("Failed to send error to EDDN", ex);
                }
            });

            thread.Name         = "EDDN message";
            thread.IsBackground = true;
            thread.Start();
        }
Esempio n. 5
0
        private static void sendMessage(EDDNBody body)
        {
            var client  = new RestClient("https://eddn.edcd.io:4430/");
            var request = new RestRequest("upload/", Method.POST);
            var msgBody = JsonConvert.SerializeObject(body, new JsonSerializerSettings {
                ContractResolver = new EDDNContractResolver()
            });

            request.AddParameter("application/json", msgBody, ParameterType.RequestBody);

            Logging.Debug("Sending " + msgBody);

            Thread thread = new Thread(() =>
            {
                IRestResponse response = null;
                try
                {
                    response = client.Execute(request);
                    if (response != null)
                    {
                        Logging.Debug("Response content is " + response.Content);
                        switch (response.StatusCode)
                        {
                        // Invalid status codes are defined at https://github.com/EDSM-NET/EDDN/blob/master/src/eddn/Gateway.py
                        case System.Net.HttpStatusCode.BadRequest:     // Code 400
                            {
                                throw new ArgumentException();
                            }

                        case System.Net.HttpStatusCode.UpgradeRequired:     // Code 426
                            {
                                Logging.Warn("EDDN schema " + body.schemaRef + " is obsolete");
                                break;
                            }
                        }
                    }
                }
                catch (ThreadAbortException)
                {
                    Logging.Debug("Thread aborted");
                }
                catch (Exception ex)
                {
                    Dictionary <string, object> data = new Dictionary <string, object>
                    {
                        { "eddnMessage", JsonConvert.SerializeObject(body?.message) },
                        { "Response", response?.Content },
                        { "Exception", ex }
                    };
                    Logging.Error("Failed to send data to EDDN", data);
                }
            })
            {
                Name         = "EDDN message",
                IsBackground = true
            };

            thread.Start();
        }
Esempio n. 6
0
        private void handleRawEvent(Event theEvent)
        {
            IDictionary <string, object> data = Deserializtion.DeserializeData(theEvent.raw);

            // Need to strip a number of entries
            data.Remove("CockpitBreach");
            data.Remove("BoostUsed");
            data.Remove("FuelLevel");
            data.Remove("FuelUsed");
            data.Remove("JumpDist");

            // Need to remove any keys ending with _Localised
            data = data.Where(x => !x.Key.EndsWith("_Localised")).ToDictionary(x => x.Key, x => x.Value);

            // Can only proceed if we know our current system

            // Need to add StarSystem to scan events - can only do so if we have the data
            if (theEvent is BeltScannedEvent || theEvent is StarScannedEvent || theEvent is BodyScannedEvent)
            {
                if (systemName == null || systemX == null || systemY == null || systemZ == null)
                {
                    Logging.Debug("Missing current starsystem information, cannot send message to EDDN");
                    return;
                }
                data.Add("StarSystem", systemName);
            }

            // Need to add StarPos to all events that don't already have them
            if (!data.ContainsKey("StarPos"))
            {
                if (systemName == null || systemX == null || systemY == null || systemZ == null)
                {
                    Logging.Debug("Missing current starsystem information, cannot send message to EDDN");
                    return;
                }
                IList <decimal> starpos = new List <decimal>
                {
                    systemX.Value,
                    systemY.Value,
                    systemZ.Value
                };
                data.Add("StarPos", starpos);
            }

            EDDNBody body = new EDDNBody
            {
                header = generateHeader(),
#if DEBUG
                // Use the test schema while in development.
                schemaRef = "https://eddn.edcd.io/schemas/journal/1/test",
#else
                schemaRef = "https://eddn.edcd.io/schemas/journal/1" + (EDDI.Instance.inBeta ? "/test" : ""),
#endif
                message = data
            };

            sendMessage(body);
        }
Esempio n. 7
0
        private static void SendToEDDN(IDictionary <string, object> data)
        {
            EDDNBody body = new EDDNBody
            {
                header    = generateHeader(),
                schemaRef = "https://eddn.edcd.io/schemas/journal/1" + (EDDI.Instance.ShouldUseTestEndpoints() ? "/test" : ""),
                message   = data
            };

            sendMessage(body);
        }
Esempio n. 8
0
        private void sendCommodityInformation()
        {
            // It's possible that the commodity data, if it is here, has already come from EDDB.  We use the average price
            // as a marker: this isn't visible in EDDB, so if we have average price we know that this is data from the companion
            // API and should be reported
            if (EDDI.Instance.CurrentStation != null && EDDI.Instance.CurrentStation.commodities != null && EDDI.Instance.CurrentStation.commodities.Count > 0 && EDDI.Instance.CurrentStation.commodities[0].avgprice != null)
            {
                List <EDDNCommodity> eddnCommodities = new List <EDDNCommodity>();
                foreach (Commodity commodity in EDDI.Instance.CurrentStation.commodities)
                {
                    if (commodity.category == "NonMarketable")
                    {
                        continue;
                    }
                    EDDNCommodity eddnCommodity = new EDDNCommodity();
                    eddnCommodity.name          = commodity.EDName;
                    eddnCommodity.meanPrice     = (int)commodity.avgprice;
                    eddnCommodity.buyPrice      = (int)commodity.buyprice;
                    eddnCommodity.stock         = (int)commodity.stock;
                    eddnCommodity.stockBracket  = commodity.stockbracket;
                    eddnCommodity.sellPrice     = (int)commodity.sellprice;
                    eddnCommodity.demand        = (int)commodity.demand;
                    eddnCommodity.demandBracket = commodity.demandbracket;
                    if (commodity.StatusFlags.Count > 0)
                    {
                        eddnCommodity.statusFlags = commodity.StatusFlags;
                    }
                    eddnCommodities.Add(eddnCommodity);
                }
                ;

                // Only send the message if we have commodities
                if (eddnCommodities.Count > 0)
                {
                    IDictionary <string, object> data = new Dictionary <string, object>();
                    data.Add("timestamp", DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
                    data.Add("systemName", systemName);
                    data.Add("stationName", EDDI.Instance.CurrentStation.name);
                    data.Add("commodities", eddnCommodities);

                    EDDNBody body = new EDDNBody();
                    body.header    = generateHeader();
                    body.schemaRef = "https://eddn.edcd.io/schemas/commodity/3" + (EDDI.Instance.inBeta ? "/test" : "");
                    body.message   = data;

                    sendMessage(body);
                }
            }
        }
Esempio n. 9
0
        private void sendCommodityInformation()
        {
            if (EDDI.Instance.LastStation != null && EDDI.Instance.LastStation.commodities != null)
            {
                List <EDDNCommodity> eddnCommodities = new List <EDDNCommodity>();
                foreach (Commodity commodity in EDDI.Instance.LastStation.commodities)
                {
                    if (commodity.category == "NonMarketable")
                    {
                        continue;
                    }
                    EDDNCommodity eddnCommodity = new EDDNCommodity();
                    eddnCommodity.name          = commodity.EDName;
                    eddnCommodity.meanPrice     = commodity.avgprice;
                    eddnCommodity.buyPrice      = commodity.buyprice;
                    eddnCommodity.stock         = commodity.stock;
                    eddnCommodity.stockBracket  = commodity.stockbracket;
                    eddnCommodity.sellPrice     = commodity.sellprice;
                    eddnCommodity.demand        = commodity.demand;
                    eddnCommodity.demandBracket = commodity.demandbracket;
                    if (commodity.StatusFlags.Count > 0)
                    {
                        eddnCommodity.statusFlags = commodity.StatusFlags;
                    }
                    eddnCommodities.Add(eddnCommodity);
                }
                ;

                // Only send the message if we have commodities
                if (eddnCommodities.Count > 0)
                {
                    IDictionary <string, object> data = new Dictionary <string, object>();
                    data.Add("timestamp", DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
                    data.Add("systemName", EDDI.Instance.LastStation.systemname);
                    data.Add("stationName", EDDI.Instance.LastStation.name);
                    data.Add("commodities", eddnCommodities);

                    EDDNBody body = new EDDNBody();
                    body.header    = generateHeader();
                    body.schemaRef = "http://schemas.elite-markets.net/eddn/commodity/3";
                    body.message   = data;

                    sendMessage(body);
                }
            }
        }
Esempio n. 10
0
 private static void SendToEDDN(string schema, IDictionary <string, object> data)
 {
     try
     {
         EDDNBody body = new EDDNBody
         {
             header    = generateHeader(),
             schemaRef = schema + (EDDI.Instance.ShouldUseTestEndpoints() ? "/test" : ""),
             message   = data
         };
         Logging.Debug("EDDN message is: " + JsonConvert.SerializeObject(body));
         sendMessage(body);
     }
     catch (Exception ex)
     {
         data.Add(new KeyValuePair <string, object>("Exception", ex));
         Logging.Error("Unable to send message to EDDN, schema " + schema, data);
     }
 }
Esempio n. 11
0
        private void sendCommodityInformation()
        {
            if (EDDI.Instance.CurrentStation != null && EDDI.Instance.CurrentStation.commodities != null && EDDI.Instance.CurrentStation.commodities.Count > 0)
            {
                List <EDDNEconomy>   eddnEconomies   = prepareEconomyInformation();
                List <EDDNCommodity> eddnCommodities = prepareCommodityInformation();

                // Only send the message if we have commodities
                if (eddnCommodities.Count > 0)
                {
                    IDictionary <string, object> data = new Dictionary <string, object>
                    {
                        { "timestamp", DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ") },
                        { "systemName", systemName },
                        { "stationName", EDDI.Instance.CurrentStation.name }
                    };
                    if (eddnEconomies.Count > 0)
                    {
                        data.Add("economies", eddnEconomies);
                    }
                    data.Add("commodities", eddnCommodities);
                    if (EDDI.Instance.CurrentStation.prohibited?.Count > 0)
                    {
                        data.Add("prohibited", EDDI.Instance.CurrentStation.prohibited);
                    }

                    EDDNBody body = new EDDNBody
                    {
                        header = generateHeader(),
#if DEBUG
                        // Use the test schema while in development.
                        schemaRef = "https://eddn.edcd.io/schemas/commodity/3/test",
#else
                        schemaRef = "https://eddn.edcd.io/schemas/commodity/3" + (EDDI.Instance.inBeta ? "/test" : ""),
#endif
                        message = data
                    };

                    Logging.Debug("EDDN message is: " + JsonConvert.SerializeObject(body));
                    sendMessage(body);
                }
            }
        }
Esempio n. 12
0
        private void handleRawEvent(Event theEvent)
        {
            IDictionary <string, object> data = Deserializtion.DeserializeData(theEvent.raw);

            // Need to strip a number of entries
            data.Remove("CockpitBreach");
            data.Remove("BoostUsed");
            data.Remove("FuelLevel");
            data.Remove("FuelUsed");
            data.Remove("JumpDist");

            // Need to remove any keys ending with _Localised
            data = data.Where(x => !x.Key.EndsWith("_Localised")).ToDictionary(x => x.Key, x => x.Value);

            // Need to add StarSystem to scan events
            if (theEvent is StarScannedEvent || theEvent is BodyScannedEvent)
            {
                data.Add("StarSystem", EDDI.Instance.CurrentStarSystem.name);
            }


            // Need to add StarPos to all events that don't already have them
            if (!data.ContainsKey("StarPos"))
            {
                if (EDDI.Instance.CurrentStarSystem == null || EDDI.Instance.CurrentStarSystem.x == null)
                {
                    Logging.Debug("Missing current starsystem information, cannot send message to EDDN");
                }
                IList <decimal> starpos = new List <decimal>();
                starpos.Add((decimal)EDDI.Instance.CurrentStarSystem.x);
                starpos.Add((decimal)EDDI.Instance.CurrentStarSystem.y);
                starpos.Add((decimal)EDDI.Instance.CurrentStarSystem.z);
                data.Add("StarPos", starpos);
            }

            EDDNBody body = new EDDNBody();

            body.header    = generateHeader();
            body.schemaRef = "http://schemas.elite-markets.net/eddn/journal/1";
            body.message   = data;

            sendMessage(body);
        }
Esempio n. 13
0
        private void sendOutfittingInformation()
        {
            if (EDDI.Instance.CurrentStation != null && EDDI.Instance.CurrentStation.outfitting != null)
            {
                List <string> eddnModules = new List <string>();
                foreach (Module module in EDDI.Instance.CurrentStation.outfitting)
                {
                    if ((!module.IsPowerPlay()) &&
                        (module.EDName.StartsWith("Int_") || module.EDName.StartsWith("Hpt_") || module.EDName.Contains("_Armour_")) &&
                        (!(module.EDName == "Int_PlanetApproachSuite")))
                    {
                        eddnModules.Add(module.EDName);
                    }
                }

                // Only send the message if we have modules
                if (eddnModules.Count > 0)
                {
                    IDictionary <string, object> data = new Dictionary <string, object>
                    {
                        { "timestamp", DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ") },
                        { "systemName", EDDI.Instance.CurrentStation.systemname },
                        { "stationName", EDDI.Instance.CurrentStation.name },
                        { "modules", eddnModules }
                    };

                    EDDNBody body = new EDDNBody
                    {
                        header = generateHeader(),
#if DEBUG
                        // Use the test schema while in development.
                        schemaRef = "https://eddn.edcd.io/schemas/outfitting/2/test",
#else
                        schemaRef = "https://eddn.edcd.io/schemas/outfitting/2" + (EDDI.Instance.inBeta ? "/test" : ""),
#endif
                        message = data
                    };

                    sendMessage(body);
                }
            }
        }
Esempio n. 14
0
        private static void sendMessage(EDDNBody body)
        {
            Logging.Debug(JsonConvert.SerializeObject(body));
            var client  = new RestClient("http://eddn-gateway.elite-markets.net:8080/");
            var request = new RestRequest("upload/", Method.POST);

            request.AddParameter("application/json", JsonConvert.SerializeObject(body), ParameterType.RequestBody);

            Logging.Debug("Sending " + JsonConvert.SerializeObject(body));

            Thread thread = new Thread(() =>
            {
                IRestResponse response = client.Execute(request);
                var content            = response.Content; // raw content as string
                Logging.Debug("Response content is " + content);
            });

            thread.Name         = "EDDN message";
            thread.IsBackground = true;
            thread.Start();
        }
Esempio n. 15
0
        private void sendShipyardInformation()
        {
            if (EDDI.Instance.CurrentStation != null && EDDI.Instance.CurrentStation.shipyard != null)
            {
                List <string> eddnShips = new List <string>();
                foreach (Ship ship in EDDI.Instance.CurrentStation.shipyard)
                {
                    eddnShips.Add(ship.EDName);
                }

                // Only send the message if we have ships
                if (eddnShips.Count > 0)
                {
                    IDictionary <string, object> data = new Dictionary <string, object>
                    {
                        { "timestamp", DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ") },
                        { "systemName", EDDI.Instance.CurrentStation.systemname },
                        { "stationName", EDDI.Instance.CurrentStation.name },
                        { "ships", eddnShips }
                    };

                    EDDNBody body = new EDDNBody
                    {
                        header = generateHeader(),
#if DEBUG
                        // Use the test schema while in development.
                        schemaRef = "https://eddn.edcd.io/schemas/shipyard/2/test",
#else
                        schemaRef = "https://eddn.edcd.io/schemas/shipyard/2" + (EDDI.Instance.inBeta ? "/test" : ""),
#endif
                        message = data
                    };

                    sendMessage(body);
                }
            }
        }
        private static void sendMessage(EDDNBody body)
        {
            Logging.Debug(JsonConvert.SerializeObject(body));
            var client = new RestClient("http://eddn-gateway.elite-markets.net:8080/");
            var request = new RestRequest("upload/", Method.POST);
            request.AddParameter("application/json", JsonConvert.SerializeObject(body), ParameterType.RequestBody);

            Logging.Debug("Sending " + JsonConvert.SerializeObject(body));

            Thread thread = new Thread(() =>
            {
                IRestResponse response = client.Execute(request);
                var content = response.Content; // raw content as string
                Logging.Debug("Response content is " + content);
            });
            thread.Name = "EDDN message";
            thread.IsBackground = true;
            thread.Start();
        }
        private void handleRawEvent(Event theEvent)
        {
            IDictionary<string, object> data = Deserializtion.DeserializeData(theEvent.raw);
            // Need to strip a number of entries
            data.Remove("CockpitBreach");
            data.Remove("BoostUsed");
            data.Remove("FuelLevel");
            data.Remove("FuelUsed");
            data.Remove("JumpDist");

            // Need to remove any keys ending with _Localised
            data = data.Where(x => !x.Key.EndsWith("_Localised")).ToDictionary(x => x.Key, x => x.Value);

            // Need to add StarSystem to scan events
            if (theEvent is StarScannedEvent || theEvent is BodyScannedEvent)
            {
                data.Add("StarSystem", EDDI.Instance.CurrentStarSystem.name);
            }


            // Need to add StarPos to all events that don't already have them
            if (!data.ContainsKey("StarPos"))
            {
                if (EDDI.Instance.CurrentStarSystem == null || EDDI.Instance.CurrentStarSystem.x == null)
                {
                    Logging.Debug("Missing current starsystem information, cannot send message to EDDN");
                }
                IList<decimal> starpos = new List<decimal>();
                starpos.Add((decimal)EDDI.Instance.CurrentStarSystem.x);
                starpos.Add((decimal)EDDI.Instance.CurrentStarSystem.y);
                starpos.Add((decimal)EDDI.Instance.CurrentStarSystem.z);
                data.Add("StarPos", starpos);
            }

            EDDNBody body = new EDDNBody();
            body.header = generateHeader();
            body.schemaRef = "http://schemas.elite-markets.net/eddn/journal/1";
            body.message = data;

            sendMessage(body);

        }
        private void sendOutfittingInformation()
        {
            if (EDDI.Instance.CurrentStation != null && EDDI.Instance.CurrentStation.outfitting != null)
            {
                List<string> eddnModules = new List<string>();
                foreach (Module module in EDDI.Instance.CurrentStation.outfitting)
                {
                    if ((!ModuleDefinitions.IsPP(module))
                        && (module.EDName.StartsWith("Int_") || module.EDName.StartsWith("Hpt_") || module.EDName.Contains("_Armour_"))
                        && (!(module.EDName == "Int_PlanetApproachSuite")))
                    {
                        eddnModules.Add(module.EDName);
                    }
                }

                // Only send the message if we have modules
                if (eddnModules.Count > 0)
                {
                    IDictionary<string, object> data = new Dictionary<string, object>();
                    data.Add("timestamp", DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
                    data.Add("systemName", EDDI.Instance.CurrentStation.systemname);
                    data.Add("stationName", EDDI.Instance.CurrentStation.name);
                    data.Add("modules", eddnModules);

                    EDDNBody body = new EDDNBody();
                    body.header = generateHeader();
                    body.schemaRef = "http://schemas.elite-markets.net/eddn/outfitting/2";
                    body.message = data;

                    sendMessage(body);
                }
            }
        }
        private void sendCommodityInformation()
        {
            if (EDDI.Instance.CurrentStation != null && EDDI.Instance.CurrentStation.commodities != null)
            {
                List<EDDNCommodity> eddnCommodities = new List<EDDNCommodity>();
                foreach (Commodity commodity in EDDI.Instance.CurrentStation.commodities)
                {
                    if (commodity.category == "NonMarketable")
                    {
                        continue;
                    }
                    EDDNCommodity eddnCommodity = new EDDNCommodity();
                    eddnCommodity.name = commodity.EDName;
                    eddnCommodity.meanPrice = commodity.avgprice;
                    eddnCommodity.buyPrice = commodity.buyprice;
                    eddnCommodity.stock = commodity.stock;
                    eddnCommodity.stockBracket = commodity.stockbracket;
                    eddnCommodity.sellPrice = commodity.sellprice;
                    eddnCommodity.demand = commodity.demand;
                    eddnCommodity.demandBracket = commodity.demandbracket;
                    if (commodity.StatusFlags.Count > 0)
                    {
                        eddnCommodity.statusFlags = commodity.StatusFlags;
                    }
                    eddnCommodities.Add(eddnCommodity);
                };

                // Only send the message if we have commodities
                if (eddnCommodities.Count > 0)
                {
                    IDictionary<string, object> data = new Dictionary<string, object>();
                    data.Add("timestamp", DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
                    data.Add("systemName", EDDI.Instance.CurrentStation.systemname);
                    data.Add("stationName", EDDI.Instance.CurrentStation.name);
                    data.Add("commodities", eddnCommodities);

                    EDDNBody body = new EDDNBody();
                    body.header = generateHeader();
                    body.schemaRef = "http://schemas.elite-markets.net/eddn/commodity/3";
                    body.message = data;

                    sendMessage(body);
                }
            }
        }