Skip to content

Commit

Permalink
Add gRPC mode switching
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbvll committed Oct 26, 2023
1 parent fa6ac3d commit f4dfb94
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions examples/quickstart-cpp/src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
#include "start.h"

int main(int argc, char **argv) {
if (argc != 3) {
std::cout << "Client takes three arguments as follows: " << std::endl;
std::cout << "./client CLIENT_ID SERVER_URL" << std::endl;
std::cout << "Example: ./flwr_client 0 '127.0.0.1:8080'" << std::endl;
if (argc != 3 && argc != 4) {
std::cout << "Client takes three mandatory arguments and one optional as "
"follows: "
<< std::endl;
std::cout << "./client CLIENT_ID SERVER_URL [GRPC_MODE]" << std::endl;
std::cout
<< "GRPC_MODE is optional and can be either 'bidi' (default) or 'rere'."
<< std::endl;
std::cout << "Example: ./flwr_client 0 '127.0.0.1:8080' bidi" << std::endl;
std::cout << "This is the same as: ./flwr_client 0 '127.0.0.1:8080'"
<< std::endl;
return 0;
}

Expand Down Expand Up @@ -38,9 +45,15 @@ int main(int argc, char **argv) {
// Define a server address
std::string server_add = SERVER_URL;

// Start client
// start::start_client(server_add, &client);
start::start_rere_client(server_add, &client);
if (argc == 4 && std::string(argv[3]) == "rere") {
std::cout << "Starting rere client" << std::endl;
// Start rere client
start::start_rere_client(server_add, &client);
} else {
std::cout << "Starting bidi client" << std::endl;
// Start bidi client
start::start_client(server_add, &client);
}

return 0;
}

0 comments on commit f4dfb94

Please sign in to comment.