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