Showing the changes to Source/Libraries/TimeSeriesPlatformLibrary/Samples/PublisherHandler.cpp (1 of 27 files). Show all
Unified · Split
| @@ -42,29 +42,23 @@ PublisherHandler::PublisherHandler(string name, uint16_t port, bool ipV6) : · 41 unmodified lines | |||
| 42 | void PublisherHandler::StatusMessage(const string& message) | 42 | void PublisherHandler::StatusMessage(const string& message) |
| 43 | { | 43 | { |
| 44 | // TODO: Make sure these messages get logged to an appropriate location | 44 | // TODO: Make sure these messages get logged to an appropriate location |
| 45 | // For now, the base class just displays to console: | ||
| 46 | stringstream status; | ||
| 47 | |||
| 48 | status << "[" << m_name << "] " << message; | ||
| 49 | 45 | ||
| 50 | // Calls can come from multiple threads, so we impose a simple lock before write to console | 46 | // Calls can come from multiple threads, so we impose a simple lock before write to console |
| 51 | s_coutLock.lock(); | 47 | ScopeLock lock(s_coutLock); |
| 52 | PublisherInstance::StatusMessage(status.str()); | 48 | |
| 53 | s_coutLock.unlock(); | 49 | // For now, we just the base class to display to console: |
| 50 | PublisherInstance::StatusMessage("[" + m_name + "] " + message); | ||
| 54 | } | 51 | } |
| 55 | 52 | ||
| 56 | void PublisherHandler::ErrorMessage(const string& message) | 53 | void PublisherHandler::ErrorMessage(const string& message) |
| 57 | { | 54 | { |
| 58 | // TODO: Make sure these messages get logged to an appropriate location | 55 | // TODO: Make sure these messages get logged to an appropriate location |
| 59 | // For now, the base class just displays to console: | ||
| 60 | stringstream status; | ||
| 61 | |||
| 62 | status << "[" << m_name << "] " << message; | ||
| 63 | 56 | ||
| 64 | // Calls can come from multiple threads, so we impose a simple lock before write to console | 57 | // Calls can come from multiple threads, so we impose a simple lock before write to console |
| 65 | s_coutLock.lock(); | 58 | ScopeLock lock(s_coutLock); |
| 66 | PublisherInstance::ErrorMessage(status.str()); | 59 | |
| 67 | s_coutLock.unlock(); | 60 | // For now, we just the base class to display to console: |
| 61 | PublisherInstance::ErrorMessage("[" + m_name + "] " + message); | ||
| 68 | } | 62 | } |
| 69 | 63 | ||
| 70 | void PublisherHandler::ClientConnected(const SubscriberConnectionPtr& connection) | 64 | void PublisherHandler::ClientConnected(const SubscriberConnectionPtr& connection) |
| @@ -187,7 +181,8 @@ void PublisherHandler::Start() · 116 unmodified lines | |||
| 187 | // data type reasonable random values every 33 milliseconds | 181 | // data type reasonable random values every 33 milliseconds |
| 188 | m_publishTimer = NewSharedPtr<Timer>(33, [this](Timer*, void*) | 182 | m_publishTimer = NewSharedPtr<Timer>(33, [this](Timer*, void*) |
| 189 | { | 183 | { |
| 190 | static uint32_t count = m_measurementMetadata.size(); | 184 | // If metadata can change, the following integer should not be static: |
| 185 | static uint32_t count = ConvertUInt32(m_measurementMetadata.size()); | ||
| 191 | const int64_t timestamp = ToTicks(UtcNow()); | 186 | const int64_t timestamp = ToTicks(UtcNow()); |
| 192 | vector<MeasurementPtr> measurements; | 187 | vector<MeasurementPtr> measurements; |
| 193 | 188 | ||