Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Remove filter from message printing #310

Merged
merged 2 commits into from
Jun 22, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ public void Destroy()

public void Receive(Message received_message)
{
if(received_message.Properties["source"] == "sensor")
{
Console.WriteLine("Printer Module received message from Sensor. Content: " + System.Text.Encoding.UTF8.GetString(received_message.Content, 0, received_message.Content.Length));
}
Console.WriteLine("Printer Module received message from " + received_message.Properties["source"] + ". Content: " + System.Text.Encoding.UTF8.GetString(received_message.Content, 0, received_message.Content.Length));
Copy link
Contributor

@aribeironovaes aribeironovaes Jun 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console.WriteLine("Printer Module received message from " + received_message.Properties["source"] + ". Content: " + System.Text.Encoding.UTF8.GetString(received_message.Content, 0, received_message.Content.Length)); [](start = 12, length = 215)

I don't think "source" property is added automatically. So, on this case you should print the Content separated from the properties.

So, please, do something like this:
if (received_message != null)
{
string messageData = System.Text.Encoding.UTF8.GetString(received_message.Content, 0, received_message.Content.Length);
Console.WriteLine("\t{0}> Received message: {1}", DateTime.Now.ToLocalTime(), messageData);

                    int propCount = 0;
                    foreach (var prop in received_message.Properties)
                    {
                        Console.WriteLine("\t\tProperty[{0}> Key={1} : Value={2}", propCount++, prop.Key, prop.Value);
                    } #Closed

}
}
}