History

TimeSeriesPlatformLibrary: (1) Improved operation of SubscriberInstance, (2) Updated function signatures for DataSubscriber to always include subscriber reference since callbacks require a static function, this allows "instance" implementations to have access to source subscriber.

J. Ritchie Carroll committed 8 years ago

Commit ddde4ba1 parent 24ecf3a7 files · +336 −230Browse files

Showing the changes to Source/Libraries/TimeSeriesPlatformLibrary/Samples/AdvancedSubscribe.cpp (1 of 7 files). Show all

Unified · Split

Source/Libraries/TimeSeriesPlatformLibrary/Samples/AdvancedSubscribe.cpp+6−6
@@ -41,9 +41,9 @@ tst::SubscriptionInfo CreateSubscriptionInfo(); · 40 unmodified lines
41 41
42// Handlers for subscriber callbacks.42// Handlers for subscriber callbacks.
43void Resubscribe(tst::DataSubscriber* source);43void Resubscribe(tst::DataSubscriber* source);
44void ProcessMeasurements(std::vector<gsfts::Measurement> newMeasurements);44void ProcessMeasurements(tst::DataSubscriber* source, std::vector<gsfts::Measurement> newMeasurements);
45void DisplayStatusMessage(std::string message);45void DisplayStatusMessage(tst::DataSubscriber* source, std::string message);
46void DisplayErrorMessage(std::string message);46void DisplayErrorMessage(tst::DataSubscriber* source, std::string message);
47 47
48// Runs the subscriber.48// Runs the subscriber.
49void RunSubscriber(std::string hostname, gsfts::uint16_t port);49void RunSubscriber(std::string hostname, gsfts::uint16_t port);
@@ -182,7 +182,7 @@ tst::SubscriberConnector CreateSubscriberConnector(std::string hostname, gsfts:: · 132 unmodified lines
182 182
183// Callback which is called when the subscriber has183// Callback which is called when the subscriber has
184// received a new packet of measurements from the publisher.184// received a new packet of measurements from the publisher.
185void ProcessMeasurements(std::vector<gsfts::Measurement> newMeasurements)185void ProcessMeasurements(tst::DataSubscriber* source, std::vector<gsfts::Measurement> newMeasurements)
186{186{
187 const std::string TimestampFormat = "%Y-%m-%d %H:%M:%S.%f";187 const std::string TimestampFormat = "%Y-%m-%d %H:%M:%S.%f";
188 const std::size_t MaxTimestampSize = 80;188 const std::size_t MaxTimestampSize = 80;
@@ -223,13 +223,13 @@ void Resubscribe(tst::DataSubscriber* source) · 34 unmodified lines
223}223}
224 224
225// Callback which is called to display status messages from the subscriber.225// Callback which is called to display status messages from the subscriber.
226void DisplayStatusMessage(std::string message)226void DisplayStatusMessage(tst::DataSubscriber* source, std::string message)
227{227{
228 std::cout << message << std::endl << std::endl;228 std::cout << message << std::endl << std::endl;
229}229}
230 230
231// Callback which is called to display error messages from the connector and subscriber.231// Callback which is called to display error messages from the connector and subscriber.
232void DisplayErrorMessage(std::string message)232void DisplayErrorMessage(tst::DataSubscriber* source, std::string message)
233{233{
234 std::cerr << message << std::endl << std::endl;234 std::cerr << message << std::endl << std::endl;
235}235}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t