-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch_client.cpp
43 lines (31 loc) · 1.03 KB
/
launch_client.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "client.hpp"
#include <iostream>
#include <string>
#include <thread>
#include <boost/asio.hpp>
int main(int argc, char *argv[]) {
try {
if(argc != 4) {
std::cerr << "Invalid amount of arguments. Intended usage: ./launch_client <host_ip> <server_port> <username>" << std::endl;
return 1;
}
std::string host_ip(argv[1]);
std::string server_port(argv[2]);
std::string user_name(argv[3]);
if(user_name.size() < 10)
while(user_name.size() < 10)
user_name.push_back(' ');
else if(user_name.size() > 10)
while(user_name.size() > 10)
user_name.pop_back();
std::cout << "Will attempt to connect to server with IPv4 address: "
<< host_ip << ":" << server_port
<< ", under the username " << user_name << "." << std::endl;
boost::asio::io_context io_context;
Client client(io_context, host_ip, server_port, user_name);
}
catch(std::exception& e) {
std::cerr << "Exception: " << e.what() << std::endl;
}
return 0;
}