Showing the changes to Source/Libraries/TimeSeriesPlatformLibrary/Samples/InstancePublish.cpp (1 of 9 files). Show all
Unified · Split
| @@ -35,7 +35,6 @@ PublisherHandler* Publisher[TotalInstances]; · 34 unmodified lines | ||
| 35 | 35 | |
| 36 | 36 | int main(int argc, char* argv[]) |
| 37 | 37 | { |
| 38 | − string hostname; | |
| 39 | 38 | uint16_t port; |
| 40 | 39 | |
| 41 | 40 | // Ensure that the necessary |
| @@ -56,28 +55,27 @@ int main(int argc, char* argv[]) · 14 unmodified lines | ||
| 56 | 55 | // Maintain the life-time of PublisherHandler instances within main |
| 57 | 56 | PublisherHandler* publisher = new PublisherHandler("Publisher " + ToString(i + 1), port + i, false); |
| 58 | 57 | |
| 59 | − // Set second publisher to only allow one connection | |
| 60 | − if (i == 1) | |
| 61 | − publisher->SetMaximumAllowedConnections(1); | |
| 58 | + // Set second publisher to only allow one connection | |
| 59 | + if (i == 1) | |
| 60 | + publisher->SetMaximumAllowedConnections(1); | |
| 62 | 61 | |
| 63 | − publisher->Start(); | |
| 64 | − Publisher[i] = publisher; | |
| 62 | + publisher->Start(); | |
| 63 | + Publisher[i] = publisher; | |
| 65 | 64 | } |
| 66 | 65 | |
| 67 | 66 | // Wait until the user presses enter before quitting. |
| 68 | 67 | string line; |
| 69 | 68 | getline(cin, line); |
| 70 | 69 | |
| 71 | − // Shutdown publisher instances | |
| 70 | + // Stop publisher instances - this stops publication | |
| 72 | 71 | for (uint32_t i = 0; i < TotalInstances; i++) |
| 73 | 72 | Publisher[i]->Stop(); |
| 74 | 73 | |
| 75 | − // Disconnect the publisher to stop background threads. | |
| 76 | − cout << "Disconnected." << endl; | |
| 77 | − | |
| 78 | − // Delete publisher instances | |
| 74 | + // Delete publisher instances - this closes sockets | |
| 79 | 75 | for (uint32_t i = 0; i < TotalInstances; i++) |
| 80 | 76 | delete Publisher[i]; |
| 81 | 77 | |
| 78 | + cout << "Publishers stopped." << endl; | |
| 79 | + | |
| 82 | 80 | return 0; |
| 83 | 81 | } |