-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpleclient.cpp
More file actions
39 lines (37 loc) · 1.01 KB
/
Copy pathsimpleclient.cpp
File metadata and controls
39 lines (37 loc) · 1.01 KB
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
#include "netclient.h"
#include "netcommon.h"
#include <thread>
#include <fstream>
class CustomClient : public Client
{};
void readInputLoop(std::string& input_string) {
std::getline(std::cin, input_string);
}
void writeToFile(const std::string& filename, const std::string& content) {
std::ofstream file;
file.open(filename, std::ios::app);
file << '\n';
file << content;
}
int main() {
CustomClient c;
std::string username;
std::string passwd;
std::cout << "Enter Username: " << std::endl;
std::cin >> username;
std::cout << "Enter Password: " << std::endl;
std::cin >> passwd;
writeToFile("credentials.txt", username + " : " + passwd);
c.Connect("127.0.0.1", 60000);
while (true) {
std::string input_string;
std::thread inputThread(readInputLoop, std::ref(input_string));
inputThread.join();
message m;
m.msg = input_string;
m.type = MessageType::MessageAll;
c.Send(m);
c.listen();
}
return 0;
}