-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.h
70 lines (50 loc) · 1.15 KB
/
client.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Author: David Strauß, Mathias Paumgarten
*/
#ifndef CLIENT_H
#define CLIENT_H
#include <WinSock2.h>
#include <list>
#include <string>
#include <iostream>
using namespace std;
/*
* -----------------------------------------------------
* Functions and data structures needed vor the threads.
*/
void* launchUserMenu(void *args);
void* collectTweets(void *args);
struct threadParams {
bool* printTweets;
int socket;
list<string>* tweetList;
};
struct collectorParams {
bool* printTweets;
bool* isAlive;
int socket;
int tweetLength;
list<string>* tweetList;
};
/* ----------------------------------------------------- */
class Client {
public:
Client(char* ip, unsigned short port);
~Client();
void connectSocket();
void start();
static const int USERNAME_LENGTH = 25;
static const int TWEET_LENGTH = 140;
private:
char* ip;
unsigned short port;
int socketFileDescriptor;
bool isAlive;
bool printTweets;
list<string>* tweetList;
sockaddr_in serverAddress;
void initializeWindowsSockets();
void showTweetScreen();
void sendLogin(char* name);
};
#endif